Skip to content

Commit

Permalink
Support JDK 20 and JDK 21 (#177)
Browse files Browse the repository at this point in the history
From JDK 20 onwards the `LAMBDA` feature enum constant is no longer
recognized. Falling back to the `RECORDS` enum constant should guarantee
support for the next few JDK releases.

Upgrading Byte Buddy from 1.12.18 to 1.14.9 introduces Java 21 byte code
support.
  • Loading branch information
Stephan202 authored Oct 26, 2023
1 parent 3cfcbfd commit 67e4018
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ configure([tasks.compileJava]) {
options.release = 8

javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(19)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand Down
2 changes: 1 addition & 1 deletion jabel-javac-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
sourceCompatibility = targetCompatibility = 8

dependencies {
implementation platform('net.bytebuddy:byte-buddy-parent:1.12.18')
implementation platform('net.bytebuddy:byte-buddy-parent:1.14.9')
implementation 'net.bytebuddy:byte-buddy'
implementation 'net.bytebuddy:byte-buddy-agent'
implementation 'net.java.dev.jna:jna:5.12.1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,13 @@ static void checkSourceLevel(
@Advice.Argument(value = 1, readOnly = false) Source.Feature feature
) {
if (feature.allowedInSource(Source.JDK8)) {
//noinspection UnusedAssignment
feature = Source.Feature.LAMBDA;
if (Source.MIN.compareTo(Source.JDK8) < 0) {
//noinspection UnusedAssignment
feature = Source.Feature.LAMBDA;
} else {
//noinspection UnusedAssignment
feature = Source.Feature.RECORDS;
}
}
}
}
Expand Down

0 comments on commit 67e4018

Please sign in to comment.