diff --git a/src/main/java11/datadog/compiler/BurningwaveModuleOpener.java b/src/main/java11/datadog/compiler/BurningwaveModuleOpener.java new file mode 100644 index 0000000..417273e --- /dev/null +++ b/src/main/java11/datadog/compiler/BurningwaveModuleOpener.java @@ -0,0 +1,26 @@ +package datadog.compiler; + +import java.util.concurrent.Executor; +import org.burningwave.core.assembler.StaticComponentContainer; +import org.burningwave.core.function.ThrowingRunnable; + +/** + * Isolates all burningwave references so that the JVM only loads burningwave classes when this + * class is explicitly accessed. This prevents {@code StaticComponentContainer.} from + * running on JDK versions where it fails (e.g. JDK 26+). + */ +class BurningwaveModuleOpener { + + static void open() { + try { + if (StaticComponentContainer.JVMInfo.getVersion() >= 16) { + StaticComponentContainer.Modules.exportToAllUnnamed("jdk.compiler"); + } + // force classes to be loaded: https://github.com/burningwave/core/discussions/15 + ThrowingRunnable.class.getClassLoader(); + Executor.class.getClassLoader(); + } catch (Throwable e) { + // ignore + } + } +} diff --git a/src/main/java11/datadog/compiler/CompilerModuleOpener.java b/src/main/java11/datadog/compiler/CompilerModuleOpener.java index 1bdd716..005b9d1 100644 --- a/src/main/java11/datadog/compiler/CompilerModuleOpener.java +++ b/src/main/java11/datadog/compiler/CompilerModuleOpener.java @@ -1,9 +1,5 @@ package datadog.compiler; -import java.util.concurrent.Executor; -import org.burningwave.core.assembler.StaticComponentContainer; -import org.burningwave.core.function.ThrowingRunnable; - public class CompilerModuleOpener { /** @@ -20,15 +16,19 @@ public class CompilerModuleOpener { * */ public static void setup() { - try { - if (StaticComponentContainer.JVMInfo.getVersion() >= 16) { - StaticComponentContainer.Modules.exportToAllUnnamed("jdk.compiler"); - } - // force classes to be loaded: https://github.com/burningwave/core/discussions/15 - ThrowingRunnable.class.getClassLoader(); - Executor.class.getClassLoader(); - } catch (Throwable e) { - // ignore + // On Java 26+, burningwave's StaticComponentContainer fails to initialize because its + // transitive dependency (jvm-driver) uses a Class.forName0 signature that was removed + // in JDK 26 (JEP 471/498). The failure prints a noisy stacktrace to stderr even though + // the exception is caught. When running with the dd-trace-java agent, module exports are + // already handled by CompilerModuleExporter via Instrumentation.redefineModule(), so + // burningwave is not needed. For standalone usage, --add-exports flags must be provided + // manually (see README). + if (Runtime.version().feature() >= 26) { + return; } + // Burningwave references are isolated in a separate class so that the JVM + // class verifier does not resolve them when CompilerModuleOpener is loaded. + // This prevents StaticComponentContainer. from running on JDK 26+. + BurningwaveModuleOpener.open(); } }