From 06777ca1950e33c339e244bf519432356115905f Mon Sep 17 00:00:00 2001 From: Stephan Schroevers Date: Fri, 28 Apr 2023 16:14:43 +0200 Subject: [PATCH] Support JDK 20 The JDK 20 release does not recognize the `LAMBDA` feature enum constant. Falling back to the `RECORDS` enum constant should guarantee support for the next few JDK releases. --- example/build.gradle | 2 +- .../com/github/bsideup/jabel/JabelCompilerPlugin.java | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/example/build.gradle b/example/build.gradle index ad4994c..69d7cb7 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -7,7 +7,7 @@ configure([tasks.compileJava]) { options.release = 8 javaCompiler = javaToolchains.compilerFor { - languageVersion = JavaLanguageVersion.of(19) + languageVersion = JavaLanguageVersion.of(20) } } diff --git a/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/JabelCompilerPlugin.java b/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/JabelCompilerPlugin.java index 4315e1e..b9b123a 100644 --- a/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/JabelCompilerPlugin.java +++ b/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/JabelCompilerPlugin.java @@ -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; + } } } }