Skip to content

Commit b7f5cfb

Browse files
committed
Add constructor to AgentClassLoader for custom parent ClassLoader
1 parent c7dd764 commit b7f5cfb

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

javaagent-bootstrap/src/main/java/io/opentelemetry/javaagent/bootstrap/AgentClassLoader.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,24 @@ public AgentClassLoader(File javaagentFile) {
8484
*/
8585
public AgentClassLoader(
8686
File javaagentFile, String internalJarFileName, boolean isSecurityManagerSupportEnabled) {
87-
super(new URL[] {}, getParentClassLoader());
87+
this(javaagentFile, internalJarFileName, isSecurityManagerSupportEnabled, null);
88+
}
89+
90+
/**
91+
* Construct a new AgentClassLoader with a custom parent ClassLoader.
92+
*
93+
* @param javaagentFile Used for resource lookups.
94+
* @param internalJarFileName File name of the internal jar
95+
* @param isSecurityManagerSupportEnabled Whether this class loader should define classes with all
96+
* permissions
97+
* @param parentClassLoader Custom parent ClassLoader to use. If null, the default parent will be used.
98+
*/
99+
public AgentClassLoader(
100+
File javaagentFile,
101+
String internalJarFileName,
102+
boolean isSecurityManagerSupportEnabled,
103+
@Nullable ClassLoader parentClassLoader) {
104+
super(new URL[] {}, parentClassLoader != null ? parentClassLoader : getParentClassLoader());
88105
if (javaagentFile == null) {
89106
throw new IllegalArgumentException("Agent jar location should be set");
90107
}

0 commit comments

Comments
 (0)