Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions javaagent-tooling/javaagent-tooling-java9/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,12 @@ tasks {
compilerArgs.add("-Xlint:none")
}
}
compileTestJava {
with(options) {
// Because this module targets Java 9, we trigger this compiler bug which was fixed but not
// backported to Java 9 compilation.
// https://bugs.openjdk.java.net/browse/JDK-8209058
compilerArgs.add("-Xlint:none")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ static void initialize(Instrumentation instrumentation, ClassLoader classLoader)
initialize(instrumentation, classLoader, true);
}

private static void initialize(
// visible for testing
static void initialize(
Instrumentation instrumentation, ClassLoader classLoader, boolean testUnsafePresent) {
Class<?> unsafeClass;
try {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.javaagent.tooling;

import static org.assertj.core.api.Assertions.assertThat;

import io.opentelemetry.javaagent.bootstrap.AgentClassLoader;
import java.io.File;
import java.net.URL;
import net.bytebuddy.agent.ByteBuddyAgent;
import org.junit.jupiter.api.Test;

class UnsafeTest {

@Test
void testGenerateSunMiscUnsafe() throws Exception {
ByteBuddyAgent.install();
URL testJarLocation =
AgentClassLoader.class.getProtectionDomain().getCodeSource().getLocation();

try (AgentClassLoader loader = new AgentClassLoader(new File(testJarLocation.toURI()))) {
UnsafeInitializer.initialize(ByteBuddyAgent.getInstrumentation(), loader, false);

Class<?> unsafeClass = loader.loadClass("sun.misc.Unsafe");

assertThat(unsafeClass.getClassLoader()).isEqualTo(loader);
}
}
}
Loading