Skip to content

Commit b35e121

Browse files
authored
Override java version 25-ea to be 24 for kotlin compiler (#9274)
1 parent 6860793 commit b35e121

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -436,11 +436,30 @@ public static Class<?> compileAndLoad(
436436
String compilerOutputDir = "/tmp/" + CapturedSnapshotTest.class.getSimpleName() + "-kotlin";
437437
args.setDestination(compilerOutputDir);
438438
args.setClasspath(System.getProperty("java.class.path"));
439-
ExitCode exitCode =
440-
compiler.execImpl(
441-
new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
442-
Services.EMPTY,
443-
args);
439+
// We are currently testing JDK 25-ea, which is not yet generally available. This is causing
440+
// Kotlin compilation issues for "25-ea" and "25". Temporarily override java.version "25-ea"
441+
// to be the latest generally available JDK version "24".
442+
// TODO: Revert this change once JDK 25 is generally available and tested.
443+
String originalJavaVersion = System.getProperty("java.version");
444+
boolean overrideEAJavaVersion =
445+
originalJavaVersion != null && originalJavaVersion.contains("-ea");
446+
ExitCode exitCode;
447+
try {
448+
if (overrideEAJavaVersion) {
449+
System.setProperty("java.version", "24");
450+
}
451+
exitCode =
452+
compiler.execImpl(
453+
new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
454+
Services.EMPTY,
455+
args);
456+
} finally {
457+
// Restore the original java.version if it was overridden (25-ea)
458+
if (overrideEAJavaVersion) {
459+
System.setProperty("java.version", originalJavaVersion);
460+
}
461+
}
462+
444463
if (exitCode.getCode() != 0) {
445464
throw new RuntimeException("Kotlin compilation failed");
446465
}

0 commit comments

Comments
 (0)