Fix DDLocationStrategy to use DataDog ClassLoader
This allows ByteBuddy to properly find classes injected into the
agent.
Thanks for providing a fix!
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/DDLocationStrategy.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/DDLocationStrategy.java
@@ -12,16 +12,14 @@ import net.bytebuddy.utility.JavaModule;
* reached.
*/
public class DDLocationStrategy implements AgentBuilder.LocationStrategy {
- private static final ClassLoader BOOTSTRAP_RESOURCE_LOCATOR = new ClassLoader(null) {};
-
@Override
- public ClassFileLocator classFileLocator(ClassLoader classLoader, JavaModule javaModule) {
- List<ClassFileLocator> locators = new ArrayList<ClassFileLocator>();
+ public ClassFileLocator classFileLocator(ClassLoader classLoader, final JavaModule javaModule) {
+ final List<ClassFileLocator> locators = new ArrayList<>();
while (classLoader != null) {
locators.add(ClassFileLocator.ForClassLoader.of(classLoader));
classLoader = classLoader.getParent();
}
- locators.add(ClassFileLocator.ForClassLoader.of(BOOTSTRAP_RESOURCE_LOCATOR));
+ locators.add(ClassFileLocator.ForClassLoader.of(Utils.getBootstrapProxy()));
return new ClassFileLocator.Compound(locators.toArray(new ClassFileLocator[0]));
}
}

Fix DDLocationStrategy to use DataDog ClassLoader

This allows ByteBuddy to properly find classes injected into the
agent.

Thanks @realark for providing a fix!