DataDog/datadog-api-client-java

Java 21 and datadog

jkvargas opened this issue · 1 comments

Describe the bug
I am not sure if this is the correct place to ask this.
But lets see,
I am facing an issue with java 21 and when adding a bean to jettyserver.
checking the stacktrace seems it could be related to datadog and the usage of unsafe,

java.lang.UnsupportedOperationException: Cannot get defined package using reflection: sun.misc.Unsafe
        at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection$Dispatcher$Initializable$Unavailable.getDefinedPackage(ClassInjector.java:479)
        at net.bytebuddy.dynamic.loading.ClassInjector$UsingReflection.injectRaw(ClassInjector.java:251)
        at datadog.trace.agent.tooling.HelperInjector.injectClassLoader(HelperInjector.java:138)
        at datadog.trace.agent.tooling.HelperInjector.transform(HelperInjector.java:105)
        at datadog.trace.agent.tooling.AdviceStack.transform(AdviceStack.java:31)
        at datadog.trace.agent.tooling.SplittingTransformer.transform(SplittingTransformer.java:28)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doTransform(AgentBuilder.java:12223)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:12160)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.access$1800(AgentBuilder.java:11869)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$Java9CapableVmDispatcher.run(AgentBuilder.java:12647)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$Java9CapableVmDispatcher.run(AgentBuilder.java:12579)
        at java.base/java.security.AccessController.doPrivileged(Unknown Source)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.doPrivileged(AgentBuilder.java)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer.transform(AgentBuilder.java:12103)
        at net.bytebuddy.agent.builder.AgentBuilder$Default$ExecutingTransformer$ByteBuddy$ModuleSupport.transform(Unknown Source)
        at datadog.trace.agent.tooling.bytebuddy.DDJava9ClassFileTransformer.transform(DDJava9ClassFileTransformer.java:60)
        at java.instrument/sun.instrument.TransformerManager.transform(Unknown Source)
        at java.instrument/sun.instrument.InstrumentationImpl.transform(Unknown Source)
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
        at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(Unknown Source)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        at org.eclipse.jetty.server.HttpChannelListeners$NotifyRequest.<clinit>(HttpChannelListeners.java:219)
        at org.eclipse.jetty.server.HttpChannelListeners.<init>(HttpChannelListeners.java:53)
        at org.eclipse.jetty.server.AbstractConnector$1.beanAdded(AbstractConnector.java:217)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:350)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.addBean(ContainerLifeCycle.java:320)

To Reproduce
connector = new ServerConnector(_server, _factory);
connector.addBean(new ChannelListener());

class ChannelListener implements HttpChannel.Listener { ... }

I am using JettyServer 11.0.15 on a linux machine, I am initializing the datadog agent with "-javaagent:/usr/lib/jvm/datadog/dd-java-agent.jar"

therve commented

Hi,

I think you need to open this at https://github.com/DataDog/dd-trace-java. Thanks!