Skip to content
Draft
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
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ jobs:
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: 'Set up JDK 28 EA from jdk.java.net'
- name: 'Set up JDK 29 EA from jdk.java.net'
uses: oracle-actions/setup-java@fff43251af9936a0e6a4d5d0946e14f1680e9b6b # v1.5.0
with:
website: jdk.java.net
release: 28
release: 29
- name: 'Set up JDKs'
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The build applies [cribro](https://github.com/cribro-dev/cribro) in `settings.gr

`./gradlew :<module>:pitestDiff -Pcribro.pitestTargetTests=<test classes>` runs [PIT](https://pitest.org/) over the lines your branch changed in the module's main sources and prints each mutant no test detected. It is not part of `test` or `check`, and a surviving mutant never fails the build. PIT runs only the tests of the module whose code it mutates. The tests in `jdk-recent-unit-tests`, `guava-recent-unit-tests`, `jar-infer/nullaway-integration-test`, and `jdk-annotations/jdk-integration-test` exercise `nullaway/src/main`, and the tests of `jar-infer/jar-infer-lib` and `jdk-annotations/astubx-generator` exercise `StubxWriter` in `library-model/library-model-generator`; none of them runs under the `pitestDiff` of the module whose code they test. PIT mutates a line that calls `Verify` or `Preconditions` like any other, so a surviving mutant that removes such a call marks a check no test makes fail. If no caller can observe a surviving mutant, mark it on its line with `// mutant: equivalent <id> -- <reason>`, where `<id>` is the text in brackets after the mutant in the report, such as `MathMutator#2`. A line marked `// diff-coverage: ignore` needs no such marker: the report lists its surviving mutants apart.

`-PenableJacoco=true` also instruments the `Test` tasks other than `test`, such as `testJdk*`, for `./gradlew codeCoverageReport`; the report gets data from `test` only while diff coverage is on. On CI, the Linux job sets it and the macOS and Windows jobs set `-Pcribro.diffCoverageEnabled=false`, so their tests run without JaCoCo.
`-PenableJacoco=true` also instruments supported `Test` tasks other than `test`, such as `testJdk*`, for `./gradlew codeCoverageReport`; the report gets data from `test` only while diff coverage is on. On CI, the Linux job sets it and the macOS and Windows jobs set `-Pcribro.diffCoverageEnabled=false`, so their tests run without JaCoCo.

Third-party projects in CI
--------------------------
Expand Down
20 changes: 11 additions & 9 deletions buildSrc/src/main/groovy/nullaway.java-test-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,19 @@ jacoco {
toolVersion = "0.8.16"
}

// -PenableJacoco=true instruments the Test tasks other than `test`, such as testJdk*, for the
// -PenableJacoco=true instruments supported Test tasks other than `test`, such as testJdk*, for the
// aggregate report in :code-coverage-report. They re-run the `test` suite under other JDKs, so
// ordinary runs leave them uninstrumented. The cribro plugin, applied in settings.gradle, instruments the `test` task itself
// for diff coverage unless -Pcribro.diffCoverageEnabled=false.
def enableJacoco = providers.gradleProperty("enableJacoco")
.map { it.toBoolean() }
.orElse(false)

tasks.withType(Test).matching { it.name != "test" }.configureEach {
// JaCoCo 0.8.16 cannot instrument JDK 29 class files.
def testWithoutJacoco = "testJdk29"
tasks.withType(Test).matching { it.name != "test" }.configureEach { testTask ->
extensions.configure(JacocoTaskExtension) { jacocoExtension ->
jacocoExtension.enabled = enableJacoco.get()
jacocoExtension.enabled = testTask.name != testWithoutJacoco && enableJacoco.get()
}
}

Expand Down Expand Up @@ -92,7 +94,7 @@ test {
}

// Tasks for testing on other JDK versions; see https://jakewharton.com/build-on-latest-java-test-through-lowest-java/
[21, 27, 28].each { majorVersion ->
[21, 27, 29].each { majorVersion ->
def jdkTest = tasks.register("testJdk$majorVersion", Test) {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(majorVersion)
Expand Down Expand Up @@ -142,13 +144,13 @@ tasks.named('check').configure {
// The built-in jacoco-report-aggregation plugin aggregates coverage per test suite,
// matching the variant whose org.gradle.testsuite.name == "test". That auto-created
// variant (coverageDataElementsForTest) only carries the default `test` task's exec
// data. testJdk17/21/27/28 are plain Test tasks that re-run the `test` source set
// under other JDKs, so without this their coverage is dropped from aggregation.
// This attaches their exec files to the `test` suite's coverage variant and
// replaces the old hand-rolled `coverageDataElements` configuration
// data. Attach the exec files from additional Test tasks that support JaCoCo to the
// `test` suite's coverage variant so the aggregate report includes their coverage.
// See https://github.com/uber/NullAway/pull/1598#issuecomment-4693680548
configurations.named('coverageDataElementsForTest') {
tasks.withType(Test).matching { it.name != 'test' }.each { testTask ->
tasks.withType(Test).matching {
it.name != 'test' && it.name != testWithoutJacoco
}.each { testTask ->
// tasks.named(...).map { } keeps the exec-file reference lazy and carries the
// task dependency, so requesting the coverage data runs the JDK-specific tests.
outgoing.artifact(
Expand Down
8 changes: 3 additions & 5 deletions jar-infer/jar-infer-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ tasks.withType(JavaCompile).configureEach {
options.compilerArgs += "--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"
}

[28].each { jdkVersion ->
tasks.getByName("testJdk${jdkVersion}").configure {
// Won't work until WALA supports this JDK version
onlyIf { false }
}
tasks.named("testJdk29") {
// WALA needs JDK 29 support before this suite can run on it.
onlyIf { false }
}
apply plugin: 'com.vanniktech.maven.publish'
Original file line number Diff line number Diff line change
Expand Up @@ -638,16 +638,11 @@ void explicitTypeArgument() {

@Test
public void methodReferenceQualifiedRootTypeIsReported() {
// A qualified name crashes javac while it parses, in TreeInfo.isStaticSym on a symbol the
// parser has not set yet, where 25 and earlier accept it. The regression arrived in 26 b23
// and is open as https://bugs.openjdk.org/browse/JDK-8391567.
//
// The upper bound is a reminder, not a claim about 29: the test runs again on 29, and passes
// there once javac is fixed. A failure on 29 says the fix has not landed, so raise the bound
// to the next release; once it passes, drop the guard and fold this fixture back into
// JDK-8391567 crashes javac while parsing this qualified method reference on JDK 26 through
// 29 EA. Retry on JDK 30. Once javac accepts it, merge this case into
// methodReferenceRootTypeIsReported.
int feature = Runtime.version().feature();
Assume.assumeTrue(feature < 26 || feature >= 29);
Assume.assumeTrue(feature < 26 || feature >= 30);
compilationHelper
.addSourceLines(
"test/References.java",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2767,10 +2767,10 @@ void put(T t) {}

@Test
public void annotatedUnboundMethodRefQualifier() {
// A qualified name crashes javac while it parses on JDK 26 through 28; see JDK-8391567.
// JDK-8391567 crashes javac while parsing the qualified reference on JDK 26 through 29 EA.
int feature = Runtime.version().feature();
String qualifiedNameInvocation =
feature < 26 || feature >= 29 ? "takeNullable(@A com.uber.Test.Box::list);" : "";
feature < 26 || feature >= 30 ? "takeNullable(@A com.uber.Test.Box::list);" : "";
makeHelper()
.addSourceLines(
"Test.java",
Expand Down
Loading