diff --git a/code-coverage-report/build.gradle b/code-coverage-report/build.gradle index e9d3da6bcd..3e5420f298 100644 --- a/code-coverage-report/build.gradle +++ b/code-coverage-report/build.gradle @@ -20,12 +20,12 @@ plugins { id 'jacoco' } -// Use JDK 17 for this module, via a toolchain. We need JDK 17 since this module -// depends on jdk17-unit-tests. +// Use JDK 21 for this module, via a toolchain. We need JDK 21 since this module +// depends on jdk-recent-unit-tests. // We must null out sourceCompatibility and targetCompatibility to use toolchains. java.sourceCompatibility = null java.targetCompatibility = null -java.toolchain.languageVersion.set JavaLanguageVersion.of(17) +java.toolchain.languageVersion.set JavaLanguageVersion.of(21) // A resolvable configuration to collect source code def sourcesPath = configurations.create("sourcesPath") { @@ -79,5 +79,5 @@ dependencies { implementation project(':jar-infer:jar-infer-lib') implementation project(':jar-infer:nullaway-integration-test') implementation project(':guava-recent-unit-tests') - implementation project(':jdk17-unit-tests') + implementation project(':jdk-recent-unit-tests') } diff --git a/jdk17-unit-tests/build.gradle b/jdk-recent-unit-tests/build.gradle similarity index 83% rename from jdk17-unit-tests/build.gradle rename to jdk-recent-unit-tests/build.gradle index 1c9f7f908d..b5573a0e2a 100644 --- a/jdk17-unit-tests/build.gradle +++ b/jdk-recent-unit-tests/build.gradle @@ -18,11 +18,11 @@ plugins { id 'nullaway.java-test-conventions' } -// Use JDK 17 for this module, via a toolchain +// Use JDK 21 for this module, via a toolchain // We must null out sourceCompatibility and targetCompatibility to use toolchains. java.sourceCompatibility = null java.targetCompatibility = null -java.toolchain.languageVersion.set JavaLanguageVersion.of(17) +java.toolchain.languageVersion.set JavaLanguageVersion.of(21) configurations { // We use this configuration to expose a module path that can be @@ -52,9 +52,6 @@ test { } tasks.getByName('testJdk21').configure { - jvmArgs += [ - // Expose a module path for tests as a JVM property. - // Used by com.uber.nullaway.jdk17.NullAwayModuleInfoTests - "-Dtest.module.path=${configurations.testModulePath.asPath}" - ] + // We don't need this task since we already run the tests on JDK 21 + onlyIf { false } } diff --git a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayInstanceOfBindingTests.java b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayInstanceOfBindingTests.java similarity index 100% rename from jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayInstanceOfBindingTests.java rename to jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayInstanceOfBindingTests.java diff --git a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayModuleInfoTests.java b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayModuleInfoTests.java similarity index 100% rename from jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayModuleInfoTests.java rename to jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayModuleInfoTests.java diff --git a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayOptionalEmptyTests.java b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayOptionalEmptyTests.java similarity index 100% rename from jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayOptionalEmptyTests.java rename to jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayOptionalEmptyTests.java diff --git a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayRecordTests.java b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayRecordTests.java similarity index 100% rename from jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayRecordTests.java rename to jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwayRecordTests.java diff --git a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java similarity index 88% rename from jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java rename to jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java index faeb145b64..6b7a1d28fe 100644 --- a/jdk17-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java +++ b/jdk-recent-unit-tests/src/test/java/com/uber/nullaway/jdk17/NullAwaySwitchTests.java @@ -25,6 +25,7 @@ import com.uber.nullaway.NullAway; import java.util.Arrays; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -174,4 +175,28 @@ public void testSwitchExprLambda() { "}") .doTest(); } + + @Ignore("requires fix for crash in Checker dataflow library") + @Test + public void testSwitchExprNullCase() { + defaultCompilationHelper + .addSourceLines( + "SwitchExpr.java", + "package com.uber;", + "import javax.annotation.Nullable;", + "class SwitchExpr {", + " public enum NullableEnum {", + " A,", + " B,", + " }", + " static Object handleNullableEnum(@Nullable NullableEnum nullableEnum) {", + " return switch (nullableEnum) {", + " case A -> new Object();", + " case B -> new Object();", + " case null -> throw new IllegalArgumentException(\"NullableEnum parameter is required\");", + " };", + " }", + "}") + .doTest(); + } } diff --git a/settings.gradle b/settings.gradle index b1fe598c56..bfafe10aff 100644 --- a/settings.gradle +++ b/settings.gradle @@ -23,7 +23,7 @@ include ':jar-infer:test-java-lib-jarinfer' include ':jar-infer:nullaway-integration-test' include ':jmh' include ':guava-recent-unit-tests' -include ':jdk17-unit-tests' +include ':jdk-recent-unit-tests' include ':code-coverage-report' include ':sample-app' include ':jar-infer:test-android-lib-jarinfer'