From 01520c6f73556a93a947b1adf1e5176bbb026568 Mon Sep 17 00:00:00 2001 From: Lauri Tulmin Date: Tue, 4 Apr 2023 15:37:52 +0300 Subject: [PATCH] Add comment that constructor is used by tests --- .../opentelemetry/javaagent/bootstrap/AgentClassLoader.java | 5 +++-- .../javaagent/bootstrap/AgentClassLoaderTest.groovy | 4 ++-- .../src/test/groovy/UnsafeTest.groovy | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java b/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java index d936071667ff..35f9079ab6d2 100644 --- a/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java +++ b/javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java @@ -69,8 +69,9 @@ public class AgentClassLoader extends URLClassLoader { private final boolean isSecurityManagerSupportEnabled; private final Manifest manifest; - public AgentClassLoader(File javaagentFile, String internalJarFileName) { - this(javaagentFile, internalJarFileName, false); + // Used by tests + public AgentClassLoader(File javaagentFile) { + this(javaagentFile, "", false); } /** diff --git a/javaagent-bootstrap/src/test/groovy/io/opentelemetry/javaagent/bootstrap/AgentClassLoaderTest.groovy b/javaagent-bootstrap/src/test/groovy/io/opentelemetry/javaagent/bootstrap/AgentClassLoaderTest.groovy index c837f7445d2a..da7193edc3b0 100644 --- a/javaagent-bootstrap/src/test/groovy/io/opentelemetry/javaagent/bootstrap/AgentClassLoaderTest.groovy +++ b/javaagent-bootstrap/src/test/groovy/io/opentelemetry/javaagent/bootstrap/AgentClassLoaderTest.groovy @@ -19,7 +19,7 @@ class AgentClassLoaderTest extends Specification { def className2 = 'some/class/Name2' // any jar would do, use opentelemety sdk URL testJarLocation = JavaVersionSpecific.getProtectionDomain().getCodeSource().getLocation() - AgentClassLoader loader = new AgentClassLoader(new File(testJarLocation.toURI()), "") + AgentClassLoader loader = new AgentClassLoader(new File(testJarLocation.toURI())) Phaser threadHoldLockPhase = new Phaser(2) Phaser acquireLockFromMainThreadPhase = new Phaser(2) @@ -58,7 +58,7 @@ class AgentClassLoaderTest extends Specification { boolean jdk8 = "1.8" == System.getProperty("java.specification.version") // sdk is a multi release jar URL multiReleaseJar = JavaVersionSpecific.getProtectionDomain().getCodeSource().getLocation() - AgentClassLoader loader = new AgentClassLoader(new File(multiReleaseJar.toURI()), "") { + AgentClassLoader loader = new AgentClassLoader(new File(multiReleaseJar.toURI())) { @Override protected String getClassSuffix() { return "" diff --git a/javaagent-tooling/javaagent-tooling-java9/src/test/groovy/UnsafeTest.groovy b/javaagent-tooling/javaagent-tooling-java9/src/test/groovy/UnsafeTest.groovy index e1d2d47cd9c8..671be3c55d5c 100644 --- a/javaagent-tooling/javaagent-tooling-java9/src/test/groovy/UnsafeTest.groovy +++ b/javaagent-tooling/javaagent-tooling-java9/src/test/groovy/UnsafeTest.groovy @@ -14,7 +14,7 @@ class UnsafeTest extends Specification { setup: ByteBuddyAgent.install() URL testJarLocation = AgentClassLoader.getProtectionDomain().getCodeSource().getLocation() - AgentClassLoader loader = new AgentClassLoader(new File(testJarLocation.toURI()), "") + AgentClassLoader loader = new AgentClassLoader(new File(testJarLocation.toURI())) UnsafeInitializer.initialize(ByteBuddyAgent.getInstrumentation(), loader, false) expect: