Skip to content

Commit

Permalink
JDK 23 support (#1034)
Browse files Browse the repository at this point in the history
Also requires bumping WALA. One of our generics tests that did not work
before now works correctly on JDK 23, so we tweak the test case
according to the running JDK version.
  • Loading branch information
msridhar authored Sep 24, 2024
1 parent f36ab25 commit 940c40e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ test {
}

// Tasks for testing on other JDK versions; see https://jakewharton.com/build-on-latest-java-test-through-lowest-java/
[21, 22].each { majorVersion ->
[21, 23].each { majorVersion ->
def jdkTest = tasks.register("testJdk$majorVersion", Test) {
onlyIf {
// Only run when using the latest Error Prone version
Expand Down
4 changes: 2 additions & 2 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def versions = [
// The version of Error Prone that NullAway is compiled and tested against
errorProneApi : errorProneVersionToCompileAgainst,
support : "27.1.1",
wala : "1.6.6",
wala : "1.6.7",
commonscli : "1.4",
autoValue : "1.10.2",
autoService : "1.1.1",
Expand Down Expand Up @@ -118,7 +118,7 @@ def test = [
springBeans : "org.springframework:spring-beans:5.3.7",
springContext : "org.springframework:spring-context:5.3.7",
grpcCore : "io.grpc:grpc-core:1.15.1", // Should upgrade, but this matches our guava version
mockito : "org.mockito:mockito-core:5.12.0",
mockito : "org.mockito:mockito-core:5.13.0",
javaxAnnotationApi : "javax.annotation:javax.annotation-api:1.3.2",
assertJ : "org.assertj:assertj-core:3.23.1",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1877,9 +1877,39 @@ public void intersectionTypeFromConditionalExprInStringConcat() {

@Test
public void intersectionTypeInvalidAssign() {
makeHelper()
.addSourceLines(
"Test.java",
String[] source;
// javac behavior differs between versions before and after 23, so we have two versions of the
// test source code
if (Runtime.version().feature() >= 23) {
source =
new String[] {
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"import java.io.Serializable;",
"public class Test {",
" interface A<T extends @Nullable Object> {}",
" static class B implements A<@Nullable String>, Serializable {}",
" static class C implements A<String>, Serializable {}",
" static void test1(Object o) {",
" var x = (A<String> & Serializable) o;",
" // BUG: Diagnostic contains: Cannot assign from type B to type A<String> & Serializable",
" x = new B();",
" // ok",
" x = new C();",
" }",
" static void test2(Object o) {",
" var x = (A<@Nullable String> & Serializable) o;",
" x = new B();",
" // BUG: Diagnostic contains: Cannot assign from type C to type A<@Nullable String> & Serializable",
" x = new C();",
" }",
"}"
};
} else {
// Before JDK 23, javac does not compute types with annotations for cast expressions, so the
// test assertions do not work as expected.
source =
new String[] {
"package com.uber;",
"import org.jspecify.annotations.Nullable;",
"import java.io.Serializable;",
Expand All @@ -1902,8 +1932,10 @@ public void intersectionTypeInvalidAssign() {
// TODO: _should_ be an error, see https://github.com/uber/NullAway/issues/1022
" x = new C();",
" }",
"}")
.doTest();
"}"
};
}
makeHelper().addSourceLines("Test.java", source).doTest();
}

@Test
Expand Down

0 comments on commit 940c40e

Please sign in to comment.