Initialize WeakMapProvider even earlier
It is used by classes delcared as static fields in AgentInstaller, so there were some cases where the fallback is being used.
MODIFY
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
dd-java-agent/agent-tooling/src/main/java/datadog/trace/agent/tooling/AgentInstaller.java
@@ -20,6 +20,11 @@ import net.bytebuddy.utility.JavaModule;
@Slf4j
public class AgentInstaller {
+ static {
+ // WeakMap is used by other classes below, so we need to register the provider first.
+ registerWeakMapProvider();
+ }
+
public static final DDLocationStrategy LOCATION_STRATEGY = new DDLocationStrategy();
public static final AgentBuilder.PoolStrategy POOL_STRATEGY = new DDCachingPoolStrategy();
private static volatile Instrumentation INSTRUMENTATION;
@@ -41,7 +46,6 @@ public class AgentInstaller {
public static ResettableClassFileTransformer installBytebuddyAgent(
final Instrumentation inst, final AgentBuilder.Listener... listeners) {
INSTRUMENTATION = inst;
- registerWeakMapProvider();
AgentBuilder agentBuilder =
new AgentBuilder.Default()

Initialize WeakMapProvider even earlier

It is used by classes delcared as static fields in AgentInstaller, so there were some cases where the fallback is being used.