From 017cffc75372d43d3d72e146d609686a47060993 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Tue, 30 Jul 2024 15:12:43 -0400 Subject: [PATCH 1/4] Prepare build for JDK 22 (and a little for 23+). The dependency changes work around the Gradle issue identified in https://github.com/eisop/checker-framework/pull/806. The flag changes prepare for new javac warnings. With this PR, my build with JDK 22 worked. My build with JDK 23 initially got far enough for me to encounter the new warnings but then started failing with the kind of weirdly nondeterministic Gradle errors we've seen before: ``` BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 67 ``` --- build.gradle | 18 ++++++++++++++++-- dataflow/build.gradle | 5 +++++ javacutil/build.gradle | 5 +++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index cbc3dd64937..7775f759220 100644 --- a/build.gradle +++ b/build.gradle @@ -47,8 +47,18 @@ ext { isJava19 = JavaVersion.current() == JavaVersion.VERSION_19 isJava20 = JavaVersion.current() == JavaVersion.VERSION_20 isJava21 = JavaVersion.current() == JavaVersion.VERSION_21 - - isJava21plus = isJava21 + isJava22 = JavaVersion.current() == JavaVersion.VERSION_22 + isJava23 = JavaVersion.current() == JavaVersion.VERSION_23 + isJava24 = JavaVersion.current() == JavaVersion.VERSION_24 + isJava25 = JavaVersion.current() == JavaVersion.VERSION_25 + isJava26 = JavaVersion.current() == JavaVersion.VERSION_26 + + isJava26plus = isJava26 + isJava25plus = isJava25 || isJava26plus + isJava24plus = isJava24 || isJava25plus + isJava23plus = isJava23 || isJava24plus + isJava22plus = isJava22 || isJava23plus + isJava21plus = isJava21 || isJava22plus isJava20plus = isJava20 || isJava21plus isJava19plus = isJava19 || isJava20plus isJava18plus = isJava18 || isJava19plus @@ -461,6 +471,10 @@ allprojects { // TODO: Ignore this-escape for now, we may want to review and suppress each one later. lint +=',-this-escape' } + if (isJava23plus && !jdk17Compiler) { + // TODO: Ignore dangling-doc-comments for now, we may want to fix them later. + lint +=',-dangling-doc-comments' + } options.compilerArgs += [ '-g', '-Werror', diff --git a/dataflow/build.gradle b/dataflow/build.gradle index c78c1cd2b60..f7dd7424c4b 100644 --- a/dataflow/build.gradle +++ b/dataflow/build.gradle @@ -9,6 +9,11 @@ dependencies { // Node implements org.plumelib.util.UniqueId, so this dependency must be "api". api "org.plumelib:plume-util:${versions.plumeUtil}" + // plume-util has an `implementation` dependency on hashmap-util. + // That follows Gradle's rules, but Gradle's rules are not entirely correct: + // https://github.com/gradle/gradle/issues/30054 + // To build with JDK 22+, we need to redeclare that dependency here. + implementation "org.plumelib:hashmap-util:${versions.hashmapUtil}" // External dependencies: // If you add an external dependency, you must shadow its packages both in the dataflow-shaded diff --git a/javacutil/build.gradle b/javacutil/build.gradle index 7bc77e7de3b..f4a17396271 100644 --- a/javacutil/build.gradle +++ b/javacutil/build.gradle @@ -17,6 +17,11 @@ dependencies { // https://mvnrepository.com/artifact/org.plumelib/plume-util implementation "org.plumelib:plume-util:${versions.plumeUtil}" implementation "org.plumelib:reflection-util:${versions.reflectionUtil}" + // plume-util has an `implementation` dependency on hashmap-util. + // That follows Gradle's rules, but Gradle's rules are not entirely correct: + // https://github.com/gradle/gradle/issues/30054 + // To build with JDK 22+, we need to redeclare that dependency here. + implementation "org.plumelib:hashmap-util:${versions.hashmapUtil}" // External dependencies: // If you add an external dependency, you must shadow its packages both in checker.jar and From 820019d366c386931b13fef9d484f21ee99bea98 Mon Sep 17 00:00:00 2001 From: Chris Povirk Date: Tue, 6 Aug 2024 12:11:35 -0400 Subject: [PATCH 2/4] Preemptively update for https://github.com/eisop/checker-framework/pull/825. This won't build until after that PR, but I haven't rebased onto it yet. --- build.gradle | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/build.gradle b/build.gradle index 7775f759220..50045fdbd4b 100644 --- a/build.gradle +++ b/build.gradle @@ -39,34 +39,6 @@ ext { // On a Java 8 JVM, use error-prone javac and source/target 8. // On a Java 9+ JVM, use the host javac, default source/target, and required module flags. isJava8 = JavaVersion.current() == JavaVersion.VERSION_1_8 - isJava14 = JavaVersion.current() == JavaVersion.VERSION_14 - isJava15 = JavaVersion.current() == JavaVersion.VERSION_15 - isJava16 = JavaVersion.current() == JavaVersion.VERSION_16 - isJava17 = JavaVersion.current() == JavaVersion.VERSION_17 - isJava18 = JavaVersion.current() == JavaVersion.VERSION_18 - isJava19 = JavaVersion.current() == JavaVersion.VERSION_19 - isJava20 = JavaVersion.current() == JavaVersion.VERSION_20 - isJava21 = JavaVersion.current() == JavaVersion.VERSION_21 - isJava22 = JavaVersion.current() == JavaVersion.VERSION_22 - isJava23 = JavaVersion.current() == JavaVersion.VERSION_23 - isJava24 = JavaVersion.current() == JavaVersion.VERSION_24 - isJava25 = JavaVersion.current() == JavaVersion.VERSION_25 - isJava26 = JavaVersion.current() == JavaVersion.VERSION_26 - - isJava26plus = isJava26 - isJava25plus = isJava25 || isJava26plus - isJava24plus = isJava24 || isJava25plus - isJava23plus = isJava23 || isJava24plus - isJava22plus = isJava22 || isJava23plus - isJava21plus = isJava21 || isJava22plus - isJava20plus = isJava20 || isJava21plus - isJava19plus = isJava19 || isJava20plus - isJava18plus = isJava18 || isJava19plus - isJava17plus = isJava17 || isJava18plus - isJava16plus = isJava16 || isJava17plus - isJava15plus = isJava15 || isJava16plus - isJava14plus = isJava14 || isJava15plus - isJava11plus = JavaVersion.current() >= JavaVersion.VERSION_11 // As of 2023-09-23, delombok doesn't yet support JDK 22; see https://projectlombok.org/changelog . skipDelombok = JavaVersion.current() > JavaVersion.VERSION_21 @@ -471,7 +443,7 @@ allprojects { // TODO: Ignore this-escape for now, we may want to review and suppress each one later. lint +=',-this-escape' } - if (isJava23plus && !jdk17Compiler) { + if (useJdkCompiler >= 23) { // TODO: Ignore dangling-doc-comments for now, we may want to fix them later. lint +=',-dangling-doc-comments' } From 803995b1f84c0fb3c31ba5dfa071ce9c481d3e99 Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Tue, 6 Aug 2024 21:13:10 -0400 Subject: [PATCH 3/4] Check for isJava8 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index e6d190cb98d..30b923ca25d 100644 --- a/build.gradle +++ b/build.gradle @@ -464,7 +464,7 @@ allprojects { // TODO: Ignore this-escape for now, we may want to review and suppress each one later. lint +=',-this-escape' } - if (useJdkCompiler >= 23) { + if (!isJava8 && useJdkCompiler >= 23) { // TODO: Ignore dangling-doc-comments for now, we may want to fix them later. lint +=',-dangling-doc-comments' } From 1e4a6dd431dc600c14b8b8e1eb85d98f80242bdd Mon Sep 17 00:00:00 2001 From: Werner Dietl Date: Wed, 7 Aug 2024 10:23:50 -0400 Subject: [PATCH 4/4] Fix javadoc link --- .../org/checkerframework/checker/optional/OptionalVisitor.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/checker/src/main/java/org/checkerframework/checker/optional/OptionalVisitor.java b/checker/src/main/java/org/checkerframework/checker/optional/OptionalVisitor.java index eb21564c5f9..c7d922d1741 100644 --- a/checker/src/main/java/org/checkerframework/checker/optional/OptionalVisitor.java +++ b/checker/src/main/java/org/checkerframework/checker/optional/OptionalVisitor.java @@ -510,7 +510,7 @@ public Void visitVariable(VariableTree tree, Void p) { * {@code x = Optional.of(Optional.of("baz"));}. However, the type of the right-hand side is * {@code Optional}, not {@code Optional>}. Therefore, to * fully check for improper types, it is necessary to examine, in the type checker, the argument - * to construction of an Optional. Method {@link handleNestedOptionalCreation} does so. + * to construction of an Optional. Method {@link #handleNestedOptionalCreation} does so. */ private final class OptionalTypeValidator extends BaseTypeValidator {