Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 3 additions & 27 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,13 @@ concurrency:
cancel-in-progress: true
jobs:
build:
name: "JDK ${{ matrix.java }} on ${{ matrix.os }} with Error Prone ${{ matrix.epVersion }}"
name: "Build and test on ${{ matrix.os }}"
strategy:
matrix:
include:
- os: ubuntu-latest
java: 11
epVersion: 2.14.0
- os: ubuntu-latest
java: 17
epVersion: 2.14.0
# last version of Error Prone that supports Java 11
- os: ubuntu-latest
java: 11
epVersion: 2.31.0
- os: macos-latest
java: 17
epVersion: 2.41.0
- os: windows-latest
java: 17
epVersion: 2.41.0
- os: ubuntu-latest
java: 17
epVersion: 2.41.0
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -42,25 +26,19 @@ jobs:
with:
java-version: |
21
17
${{ matrix.java }}
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build and test using Java ${{ matrix.java }} and Error Prone ${{ matrix.epVersion }}
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
- name: Build and test
run: ./gradlew build
- name: Run shellcheck
run: ./gradlew shellcheck
if: runner.os == 'Linux'
- name: Aggregate jacoco coverage
id: jacoco_report
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
run: ./gradlew codeCoverageReport
continue-on-error: true
if: runner.os == 'Linux' && matrix.java == '17' && matrix.epVersion == '2.41.0' && github.repository == 'uber/NullAway'
if: runner.os == 'Linux' && github.repository == 'uber/NullAway'
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
Expand All @@ -69,11 +47,9 @@ jobs:
if: steps.jacoco_report.outcome == 'success'
- name: Test publishToMavenLocal flow
env:
ORG_GRADLE_PROJECT_epApiVersion: ${{ matrix.epVersion }}
ORG_GRADLE_PROJECT_VERSION_NAME: '0.0.0.1-LOCAL'
ORG_GRADLE_PROJECT_RELEASE_SIGNING_ENABLED: 'false'
run: ./gradlew publishToMavenLocal
if: matrix.java == '17'
- name: Check that Git tree is clean after build and test
run: ./.buildscript/check_git_clean.sh
compile-other-projects:
Expand Down
48 changes: 17 additions & 31 deletions buildSrc/src/main/groovy/nullaway.java-test-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,28 +44,28 @@ configurations.create('transitiveSourcesElements') {
}
}

// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
def commonJavacOpens = [
"--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",
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
Comment on lines +47 to +60

@coderabbitai coderabbitai Bot Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add missing --add-exports for javac code/comp (otherwise EP breaks on JDK 17/24).

Error Prone references types in com.sun.tools.javac.code and .comp at compile time; opening is not enough. Without corresponding --add-exports for these packages, you’ll hit “package is not visible”/IllegalAccess errors on newer JDKs.

Apply this diff to complete the set:

 def commonJavacOpens = [
     "--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.code=ALL-UNNAMED",
+    "--add-exports=jdk.compiler/com.sun.tools.javac.comp=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",
     "--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
 ]

Nit: consider renaming variable to commonJavacArgs since it contains both exports and opens.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// to expose necessary JDK types on JDK 16+; see https://errorprone.info/docs/installation#java-9-and-newer
def commonJavacOpens = [
"--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",
"--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
def commonJavacOpens = [
"--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.code=ALL-UNNAMED",
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=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",
"--add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
]
🤖 Prompt for AI Agents
In buildSrc/src/main/groovy/nullaway.java-test-conventions.gradle around lines
47 to 60, add missing
"--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED" and
"--add-exports=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED" to the
commonJavacOpens list so Error Prone can access those packages at compile time;
optionally rename the variable to commonJavacArgs to reflect that it contains
both --add-exports and --add-opens entries.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these opens are just used for running tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

, the current configuration with just --add-opens might be sufficient if Error Prone only accesses these packages through reflection during test runs.

If the current test configuration is working properly on JDK 17 and 24, then the existing --add-opens entries are adequate for the test execution context. My previous suggestion may have been overly cautious for this specific use case.

🐰💭


🧠 Learnings used
Learnt from: msridhar
PR: uber/NullAway#1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.


test {
maxHeapSize = "1024m"
// 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",
]
jvmArgs += commonJavacOpens
}

// Tasks for testing on other JDK versions; see https://jakewharton.com/build-on-latest-java-test-through-lowest-java/
[21, 24].each { majorVersion ->
[17, 24].each { majorVersion ->
def jdkTest = tasks.register("testJdk$majorVersion", Test) {
onlyIf {
// Only run when using the latest Error Prone version
Expand All @@ -83,21 +83,7 @@ test {
classpath = testTask.classpath
testClassesDirs = testTask.testClassesDirs
maxHeapSize = "1024m"
// 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",
]
jvmArgs += commonJavacOpens
}

tasks.named('check').configure {
Expand Down
4 changes: 2 additions & 2 deletions jdk-recent-unit-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ plugins {
id 'nullaway.java-test-conventions'
}

// Use JDK 21 for this module, via a toolchain
// Use JDK 24 for this module, via a toolchain
// We must null out sourceCompatibility and targetCompatibility to use toolchains.
java.sourceCompatibility = null
java.targetCompatibility = null
Expand Down Expand Up @@ -54,7 +54,7 @@ tasks.withType(Test).configureEach { test ->
}

// Disable tasks for specific JDK versions; we only run on the recent JDK version specified above
tasks.getByName('testJdk21').configure {
tasks.getByName('testJdk17').configure {
onlyIf { false }
}
tasks.getByName('testJdk24').configure {
Expand Down
11 changes: 0 additions & 11 deletions nullaway/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,3 @@ tasks.register('buildWithNullAway', JavaCompile) {
project.tasks.named('check').configure {
dependsOn 'buildWithNullAway'
}

tasks.withType(Test).configureEach { test ->
// hack: for some reasons the ErrorProneCLIFlagsConfigTest does not pass on EP 2.31.0,
// though it passes on both older and newer Error Prone versions (???). Not worth tracking
// down
if (deps.versions.errorProneApi == "2.31.0") {
test.filter {
excludeTestsMatching "com.uber.nullaway.ErrorProneCLIFlagsConfigTest"
}
}
}