Skip to content

Commit

Permalink
Update to WALA 1.6.1 and remove ability to build on JDK 8 (#777)
Browse files Browse the repository at this point in the history
WALA now runs on JDK 17. So, with this update, we can run our full build
on JDK 17, including JarInfer. Since WALA has required JDK 11 since
version 1.6.0, JarInfer now requires a JDK 11 VM to run, and will no
longer run on JDK 8. In order to get everything to build with this new
dependence, we have removed support for building on JDK 8. NullAway
itself will still run as part of a JDK 8 build (and it still tested
there, see #778), but running JarInfer now requires JDK 11. Much of this
PR is cleanup enabled by removing support for building on JDK 8.
  • Loading branch information
msridhar authored Jul 8, 2023
1 parent ec64e82 commit 188632b
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 238 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ jobs:
strategy:
matrix:
include:
- os: ubuntu-latest
java: 8
epVersion: 2.4.0
- os: ubuntu-latest
java: 11
epVersion: 2.4.0
Expand Down Expand Up @@ -47,13 +44,6 @@ jobs:
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
- name: Build and test using Java 8 and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: build
if: matrix.java == '8'
- name: Build and test using Java 11 and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
Expand All @@ -66,7 +56,7 @@ jobs:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
uses: gradle/gradle-build-action@v2
with:
arguments: build -x :jar-infer:jar-infer-lib:build -x :jar-infer:nullaway-integration-test:build -x :jar-infer:test-java-lib-jarinfer:build
arguments: build
if: matrix.java == '17'
- name: Report jacoco coverage
uses: gradle/gradle-build-action@v2
Expand All @@ -84,7 +74,7 @@ jobs:
uses: gradle/gradle-build-action@v2
with:
arguments: publishToMavenLocal -x signMavenPublication -x signShadowPublication
if: matrix.java == '8'
if: matrix.java == '11'
- name: Check that Git tree is clean after build and test
run: ./.buildscript/check_git_clean.sh
publish_snapshot:
Expand All @@ -95,10 +85,10 @@ jobs:
steps:
- name: 'Check out repository'
uses: actions/checkout@v3
- name: 'Set up JDK 8'
- name: 'Set up JDK 11'
uses: actions/setup-java@v3
with:
java-version: 8
java-version: 11
distribution: 'temurin'
- name: 'Publish'
uses: gradle/gradle-build-action@v2
Expand Down
34 changes: 15 additions & 19 deletions annotations/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,21 @@ dependencies {

test {
maxHeapSize = "1024m"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}

apply plugin: 'com.vanniktech.maven.publish'
68 changes: 26 additions & 42 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,42 +57,33 @@ subprojects { project ->
}
project.tasks.withType(JavaCompile) {
dependsOn(installGitHooks)
if (JavaVersion.current().isJava9Compatible()) {
options.compilerArgs += [
"-Xlint:deprecation",
"-Xlint:rawtypes",
"-Xlint:unchecked",
"-Werror"
]
options.errorprone {
// disable warnings in generated code; AutoValue code fails UnnecessaryParentheses check
disableWarningsInGeneratedCode = true
// this check is too noisy
check("StringSplitter", CheckSeverity.OFF)
// https://github.com/google/error-prone/issues/3366
check("CanIgnoreReturnValueSuggester", CheckSeverity.OFF)
// turn up various checks
check("WildcardImport", CheckSeverity.ERROR)
check("MissingBraces", CheckSeverity.ERROR)
check("TypeToString", CheckSeverity.ERROR)
check("SymbolToString", CheckSeverity.ERROR)
check("MultipleTopLevelClasses", CheckSeverity.ERROR)
check("ClassName", CheckSeverity.ERROR)
check("PackageLocation", CheckSeverity.ERROR)
check("UnnecessaryAnonymousClass", CheckSeverity.ERROR)
check("UnusedException", CheckSeverity.ERROR)
// To enable auto-patching, uncomment the line below, replace [CheckerName] with
// the checker(s) you want to apply patches for (comma-separated), and above, disable
// "-Werror"
options.compilerArgs += [
"-Xlint:deprecation",
"-Xlint:rawtypes",
"-Xlint:unchecked",
"-Werror"
]
options.errorprone {
// disable warnings in generated code; AutoValue code fails UnnecessaryParentheses check
disableWarningsInGeneratedCode = true
// this check is too noisy
check("StringSplitter", CheckSeverity.OFF)
// https://github.com/google/error-prone/issues/3366
check("CanIgnoreReturnValueSuggester", CheckSeverity.OFF)
// turn up various checks
check("WildcardImport", CheckSeverity.ERROR)
check("MissingBraces", CheckSeverity.ERROR)
check("TypeToString", CheckSeverity.ERROR)
check("SymbolToString", CheckSeverity.ERROR)
check("MultipleTopLevelClasses", CheckSeverity.ERROR)
check("ClassName", CheckSeverity.ERROR)
check("PackageLocation", CheckSeverity.ERROR)
check("UnnecessaryAnonymousClass", CheckSeverity.ERROR)
check("UnusedException", CheckSeverity.ERROR)
// To enable auto-patching, uncomment the line below, replace [CheckerName] with
// the checker(s) you want to apply patches for (comma-separated), and above, disable
// "-Werror"
// errorproneArgs.addAll("-XepPatchChecks:[CheckerName]", "-XepPatchLocation:IN_PLACE")
}
} else {
// Disable Error Prone checks on JDK 8, as more recent Error Prone versions don't run on JDK 8
// NOTE: we use disableAllChecks rather than the enabled flag because we still want to use the
// JDK 9 javac packaged with Error Prone, to work around the following bug with JDK 8 javac
// and use of the @NullMarked / @NullUnmarked annotations from jspecify:
// https://github.com/jspecify/jspecify/issues/302
options.errorprone.disableAllChecks = true
}
}

Expand All @@ -103,13 +94,6 @@ subprojects { project ->
java.targetCompatibility = "1.8"
}

// Ensure we are running on Java 8 whenever publishing to remote repos
tasks.withType(PublishToMavenRepository) {
doFirst {
assert JavaVersion.current() == JavaVersion.VERSION_1_8 : "Only publish to remote repos on JDK 1.8"
}
}

tasks.withType(Test).configureEach {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
Expand Down
7 changes: 3 additions & 4 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ import org.gradle.util.VersionNumber
def oldestErrorProneVersion = "2.4.0"
// Latest released Error Prone version that we've tested with
def latestErrorProneVersion = "2.20.0"
// Default to using latest tested Error Prone version, except on Java 8, where 2.10.0 is the last version
// that works
def defaultErrorProneVersion = JavaVersion.current() >= JavaVersion.VERSION_11 ? latestErrorProneVersion : "2.10.0"
// Default to using latest tested Error Prone version
def defaultErrorProneVersion = latestErrorProneVersion
def errorProneVersionToCompileAgainst = defaultErrorProneVersion

// If the epApiVersion project property is set, compile and test against that version of Error Prone
Expand All @@ -49,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.5.8",
wala : "1.6.1",
commonscli : "1.4",
autoValue : "1.9",
autoService : "1.0.1",
Expand Down
74 changes: 34 additions & 40 deletions guava-recent-unit-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,50 +33,44 @@ dependencies {

test {
maxHeapSize = "1024m"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}

if (JavaVersion.current() >= JavaVersion.VERSION_11) {
// Create a task to test on JDK 8
def jdk8Test = tasks.register("testJdk8", Test) {
onlyIf {
// Only if we are using a version of Error Prone compatible with JDK 8
deps.versions.errorProneApi == "2.4.0"
}
// Create a task to test on JDK 8
def jdk8Test = tasks.register("testJdk8", Test) {
onlyIf {
// Only if we are using a version of Error Prone compatible with JDK 8
deps.versions.errorProneApi == "2.4.0"
}

javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(8)
}

description = "Runs the test suite on JDK 8"
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Runs the test suite on JDK 8"
group = LifecycleBasePlugin.VERIFICATION_GROUP

// Copy inputs from normal Test task.
def testTask = tasks.getByName("test")
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
}
// Copy inputs from normal Test task.
def testTask = tasks.getByName("test")
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
}

tasks.named('check').configure {
dependsOn(jdk8Test)
}
tasks.named('check').configure {
dependsOn(jdk8Test)
}
4 changes: 4 additions & 0 deletions jar-infer/jar-infer-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ plugins {
id "com.github.johnrengelman.shadow"
}

// JarInfer requires JDK 11+, due to its dependence on WALA
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11

repositories {
mavenCentral()
}
Expand Down
46 changes: 24 additions & 22 deletions jar-infer/jar-infer-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ plugins {
id 'nullaway.jacoco-conventions'
}

// JarInfer requires JDK 11+, due to its dependence on WALA
sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_11

repositories {
mavenCentral()
// uncomment if you want to use wala.dalvik or wala.scandroid
Expand All @@ -43,28 +47,26 @@ dependencies {

test {
maxHeapSize = "1024m"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
}
if (JavaVersion.current() >= JavaVersion.VERSION_11) {
dependsOn ':jar-infer:test-android-lib-jarinfer:bundleReleaseAar'
}
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
// Accessed by Lombok tests
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
dependsOn ':jar-infer:test-android-lib-jarinfer:bundleReleaseAar'
}

tasks.withType(JavaCompile).configureEach {
options.compilerArgs += "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"
}

apply plugin: 'com.vanniktech.maven.publish'
30 changes: 13 additions & 17 deletions jar-infer/nullaway-integration-test/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,17 @@ dependencies {

test {
maxHeapSize = "1024m"
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
}
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
jvmArgs += [
"--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
}
1 change: 0 additions & 1 deletion jmh/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ jmh {

// don't run test task on pre-JDK-11 VMs
tasks.named('test') {
onlyIf { JavaVersion.current() >= JavaVersion.VERSION_11 }
// pass the extra JVM args so we can compile benchmarks in unit tests
jvmArgs extraJVMArgs
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
Expand Down
Loading

0 comments on commit 188632b

Please sign in to comment.