Skip to content

Commit 8f34523

Browse files
authored
Fix Kotlin unit test running on JDK 25 (#9646)
upgraded the Kotlin compiler version to 2.1.21
1 parent bd0c1fb commit 8f34523

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

dd-java-agent/agent-debugger/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dependencies {
5454
testImplementation group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: '2.3.5.RELEASE'
5555
testImplementation group: 'org.freemarker', name: 'freemarker', version: '2.3.30'
5656
testImplementation group: 'org.jooq', name: 'joor-java-8', version: '0.9.13'
57-
testImplementation group: 'org.jetbrains.kotlin', name: 'kotlin-compiler-embeddable', version: "1.9.25"
57+
testImplementation group: 'org.jetbrains.kotlin', name: 'kotlin-compiler-embeddable', version: "2.1.21"
5858
testImplementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: "1.0.0"
5959
testImplementation project(':dd-trace-core')
6060
testImplementation project(':dd-java-agent:agent-builder')

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@
7676
import java.util.Map;
7777
import java.util.Optional;
7878
import java.util.stream.Collectors;
79+
import org.jetbrains.kotlin.com.intellij.util.lang.JavaVersion;
7980
import org.joor.Reflect;
8081
import org.joor.ReflectException;
8182
import org.junit.jupiter.api.Assertions;
8283
import org.junit.jupiter.api.Disabled;
8384
import org.junit.jupiter.api.Test;
8485
import org.junit.jupiter.api.condition.DisabledIf;
8586
import org.junit.jupiter.api.condition.EnabledForJreRange;
86-
import org.junit.jupiter.api.condition.EnabledOnJre;
8787
import org.junit.jupiter.api.condition.JRE;
8888
import org.junit.jupiter.params.ParameterizedTest;
8989
import org.junit.jupiter.params.provider.ValueSource;
@@ -639,11 +639,12 @@ public void sourceFileProbeGroovy() throws IOException, URISyntaxException {
639639
}
640640

641641
@Test
642-
@EnabledForJreRange(max = JRE.JAVA_24)
643642
@DisabledIf(
644643
value = "datadog.environment.JavaVirtualMachine#isJ9",
645644
disabledReason = "Issue with J9 when compiling Kotlin code")
646645
public void sourceFileProbeKotlin() throws IOException, URISyntaxException {
646+
System.out.println(JavaVersion.class.getProtectionDomain().getCodeSource().getLocation());
647+
System.out.println("Java version:" + JavaVersion.current().feature);
647648
final String CLASS_NAME = "CapturedSnapshot301";
648649
int line = getLineForLineProbe(CLASS_NAME, KOTLIN_EXT, LINE_PROBE_ID1);
649650
TestSnapshotListener listener =
@@ -670,7 +671,6 @@ public void sourceFileProbeKotlin() throws IOException, URISyntaxException {
670671
}
671672

672673
@Test
673-
@EnabledForJreRange(max = JRE.JAVA_24)
674674
@DisabledIf(
675675
value = "datadog.environment.JavaVirtualMachine#isJ9",
676676
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -698,7 +698,6 @@ public void suspendKotlin() throws IOException, URISyntaxException {
698698
}
699699

700700
@Test
701-
@EnabledForJreRange(max = JRE.JAVA_24)
702701
@DisabledIf(
703702
value = "datadog.environment.JavaVirtualMachine#isJ9",
704703
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -732,7 +731,6 @@ public void suspendMethodKotlin() {
732731
}
733732

734733
@Test
735-
@EnabledForJreRange(max = JRE.JAVA_24)
736734
@DisabledIf(
737735
value = "datadog.environment.JavaVirtualMachine#isJ9",
738736
disabledReason = "Issue with J9 when compiling Kotlin code")
@@ -2583,7 +2581,7 @@ private void doSamplingTest(TestMethod testRun, int expectedGlobalCount, int exp
25832581
}
25842582

25852583
@Test
2586-
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_21})
2584+
@EnabledForJreRange(min = JRE.JAVA_17)
25872585
public void record() throws IOException, URISyntaxException {
25882586
final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot29";
25892587
final String RECORD_NAME = "com.datadog.debugger.MyRecord1";
@@ -2603,7 +2601,7 @@ public void record() throws IOException, URISyntaxException {
26032601
}
26042602

26052603
@Test
2606-
@EnabledOnJre({JRE.JAVA_17, JRE.JAVA_21})
2604+
@EnabledForJreRange(min = JRE.JAVA_17)
26072605
public void lineRecord() throws IOException, URISyntaxException {
26082606
final String CLASS_NAME = "com.datadog.debugger.CapturedSnapshot29";
26092607
final String RECORD_NAME = "com.datadog.debugger.MyRecord2";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ public static Class<?> compileAndLoad(
437437
args.setDestination(compilerOutputDir);
438438
args.setClasspath(System.getProperty("java.class.path"));
439439
ExitCode exitCode =
440-
compiler.execImpl(
440+
compiler.exec(
441441
new PrintingMessageCollector(System.out, MessageRenderer.WITHOUT_PATHS, true),
442442
Services.EMPTY,
443443
args);

0 commit comments

Comments
 (0)