Skip to content

Commit

Permalink
Remove dependency on Java 8 javac
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed May 9, 2024
1 parent 1eea838 commit 4aaaf99
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ not suffer that run-time exception.

## How to run the checker

Java 11 or later is required.

First, publish the checker to your local Maven repository by running
`./gradlew publishToMavenLocal` in this repository.

Expand Down
43 changes: 19 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ dependencies {
implementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
}

compileOnly "com.google.errorprone:javac:9+181-r4173-1"

// Testing
testImplementation 'junit:junit:4.13.2'
testImplementation "org.checkerframework:framework-test:${versions.checkerFramework}"

errorproneJavac "com.google.errorprone:javac:9+181-r4173-1"
}

tasks.withType(JavaCompile).all {
Expand All @@ -63,27 +59,26 @@ publishing {
test {
inputs.files("tests/dividebyzero")
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=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.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",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
ant.fail('Use Java 11 or later')
}
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=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.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",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
testLogging {
showStandardStreams = true
// Show the found unexpected diagnostics and expected diagnostics not found.
Expand Down

0 comments on commit 4aaaf99

Please sign in to comment.