From 8aa7afcc3fd21195d5b3359fda58fdec2b7fdeac Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Mon, 30 Mar 2026 12:32:57 +0200 Subject: [PATCH 1/2] fix: skip burningwave initialization in jdk26 --- .../java11/datadog/compiler/CompilerModuleOpener.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java11/datadog/compiler/CompilerModuleOpener.java b/src/main/java11/datadog/compiler/CompilerModuleOpener.java index 1bdd716..32a25a4 100644 --- a/src/main/java11/datadog/compiler/CompilerModuleOpener.java +++ b/src/main/java11/datadog/compiler/CompilerModuleOpener.java @@ -20,6 +20,16 @@ public class CompilerModuleOpener { * */ public static void setup() { + // 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; + } try { if (StaticComponentContainer.JVMInfo.getVersion() >= 16) { StaticComponentContainer.Modules.exportToAllUnnamed("jdk.compiler"); From 92b084af69fb7c1a476ae94ee9caf676279e5425 Mon Sep 17 00:00:00 2001 From: Daniel Mohedano Date: Tue, 31 Mar 2026 13:01:57 +0200 Subject: [PATCH 2/2] fix: move burningwave initialization to separate class --- .../compiler/BurningwaveModuleOpener.java | 26 +++++++++++++++++++ .../compiler/CompilerModuleOpener.java | 18 +++---------- 2 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 src/main/java11/datadog/compiler/BurningwaveModuleOpener.java 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 32a25a4..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 { /** @@ -30,15 +26,9 @@ public static void setup() { if (Runtime.version().feature() >= 26) { return; } - 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 - } + // 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(); } }