Skip to content

Commit 6ee8a2a

Browse files
committed
Add EA workarounds
1 parent a31f68f commit 6ee8a2a

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

buildSrc/src/main/kotlin/datadog/gradle/plugin/testJvmConstraints/TestJvmSpec.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class TestJvmSpec(val project: Project) {
2828
if (testJvm == "stable") {
2929
val javaVersions = project.providers.environmentVariablesPrefixedBy("JAVA_").map { javaHomes ->
3030
javaHomes
31-
.filter { it.key.matches(Regex("^JAVA_[0-9]+_HOME$")) }
31+
.filter { it.key.matches(Regex("^JAVA_[0-9]+_HOME$")) && it.key != "JAVA_26_HOME" } // JDK 26 is EA
3232
.map { Regex("^JAVA_(\\d+)_HOME$").find(it.key)!!.groupValues[1].toInt() }
3333
}.get()
3434

dd-java-agent/agent-debugger/src/test/java/com/datadog/debugger/agent/CapturingTestBase.java

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -425,11 +425,33 @@ public static Class<?> compileAndLoad(
425425
String compilerOutputDir = "/tmp/" + CapturedSnapshotTest.class.getSimpleName() + "-kotlin";
426426
args.setDestination(compilerOutputDir);
427427
args.setClasspath(System.getProperty("java.class.path"));
428-
ExitCode exitCode =
429-
compiler.exec(
430-
new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
431-
Services.EMPTY,
432-
args);
428+
// Temporarily patch `java.version` for Java 26-ea compatibility.
429+
// We are using the following early access version of Java 26:
430+
// https://hub.docker.com/layers/library/openjdk/26-ea-jdk-bookworm/images/sha256-d8323bd0ab1a5c12e93a46fcc6b9817d25e5a6a3cbd9505b8d57d13eea9d18e2
431+
// TODO: Fix for Java 26. Revert change once GA version of Java 26 is released (Mar 2026).
432+
// ExitCode exitCode =
433+
// compiler.exec(
434+
// new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
435+
// Services.EMPTY,
436+
// args);
437+
String originalJavaVersion = System.getProperty("java.version");
438+
boolean overrideEAJavaVersion =
439+
originalJavaVersion != null && originalJavaVersion.contains("-ea");
440+
ExitCode exitCode;
441+
try {
442+
if (overrideEAJavaVersion) {
443+
System.setProperty("java.version", "25");
444+
}
445+
exitCode =
446+
compiler.exec(
447+
new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
448+
Services.EMPTY,
449+
args);
450+
} finally {
451+
if (overrideEAJavaVersion) {
452+
System.setProperty("java.version", originalJavaVersion);
453+
}
454+
}
433455

434456
if (exitCode.getCode() != 0) {
435457
throw new RuntimeException("Kotlin compilation failed");

0 commit comments

Comments
 (0)