Skip to content

Commit

Permalink
Add comment that constructor is used by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit committed Apr 4, 2023
1 parent 8f413da commit 01520c6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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 ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 01520c6

Please sign in to comment.