Skip to content

Commit bd1d6ee

Browse files
Skip burningwave initialization in JDK26 (#19)
1 parent 10d345c commit bd1d6ee

2 files changed

Lines changed: 39 additions & 13 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package datadog.compiler;
2+
3+
import java.util.concurrent.Executor;
4+
import org.burningwave.core.assembler.StaticComponentContainer;
5+
import org.burningwave.core.function.ThrowingRunnable;
6+
7+
/**
8+
* Isolates all burningwave references so that the JVM only loads burningwave classes when this
9+
* class is explicitly accessed. This prevents {@code StaticComponentContainer.<clinit>} from
10+
* running on JDK versions where it fails (e.g. JDK 26+).
11+
*/
12+
class BurningwaveModuleOpener {
13+
14+
static void open() {
15+
try {
16+
if (StaticComponentContainer.JVMInfo.getVersion() >= 16) {
17+
StaticComponentContainer.Modules.exportToAllUnnamed("jdk.compiler");
18+
}
19+
// force classes to be loaded: https://github.com/burningwave/core/discussions/15
20+
ThrowingRunnable.class.getClassLoader();
21+
Executor.class.getClassLoader();
22+
} catch (Throwable e) {
23+
// ignore
24+
}
25+
}
26+
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package datadog.compiler;
22

3-
import java.util.concurrent.Executor;
4-
import org.burningwave.core.assembler.StaticComponentContainer;
5-
import org.burningwave.core.function.ThrowingRunnable;
6-
73
public class CompilerModuleOpener {
84

95
/**
@@ -20,15 +16,19 @@ public class CompilerModuleOpener {
2016
* </ul>
2117
*/
2218
public static void setup() {
23-
try {
24-
if (StaticComponentContainer.JVMInfo.getVersion() >= 16) {
25-
StaticComponentContainer.Modules.exportToAllUnnamed("jdk.compiler");
26-
}
27-
// force classes to be loaded: https://github.com/burningwave/core/discussions/15
28-
ThrowingRunnable.class.getClassLoader();
29-
Executor.class.getClassLoader();
30-
} catch (Throwable e) {
31-
// ignore
19+
// On Java 26+, burningwave's StaticComponentContainer fails to initialize because its
20+
// transitive dependency (jvm-driver) uses a Class.forName0 signature that was removed
21+
// in JDK 26 (JEP 471/498). The failure prints a noisy stacktrace to stderr even though
22+
// the exception is caught. When running with the dd-trace-java agent, module exports are
23+
// already handled by CompilerModuleExporter via Instrumentation.redefineModule(), so
24+
// burningwave is not needed. For standalone usage, --add-exports flags must be provided
25+
// manually (see README).
26+
if (Runtime.version().feature() >= 26) {
27+
return;
3228
}
29+
// Burningwave references are isolated in a separate class so that the JVM
30+
// class verifier does not resolve them when CompilerModuleOpener is loaded.
31+
// This prevents StaticComponentContainer.<clinit> from running on JDK 26+.
32+
BurningwaveModuleOpener.open();
3333
}
3434
}

0 commit comments

Comments
 (0)