Skip to content

Commit e950738

Browse files
committed
Treat all packages as @NullMarked
* For NullAway, the config is now in the build setup because it doesn't yet support module descriptors (see uber/NullAway#1083) * For IntelliJ, the config is now in the module descriptors
1 parent 073323e commit e950738

File tree

20 files changed

+18
-49
lines changed

20 files changed

+18
-49
lines changed

CONTRIBUTING.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ See [`ExtensionContext`](junit-jupiter-api/src/main/java/org/junit/jupiter/api/e
120120
[`ParameterContext`](junit-jupiter-api/src/main/java/org/junit/jupiter/api/extension/ParameterContext.java) for example Javadoc.
121121

122122

123+
### Nullability
124+
125+
This project uses JSpecify's annotation to indicate nullability. In general, the approach
126+
is as follows:
127+
128+
- The Gradle build is set up to treat all code as being `@NullMarked`
129+
- The descriptor of each module is annotated with `@NullMarked` for IDEs such as IntelliJ
130+
IDEA to treat code correctly.
131+
- Fields, parameters, return types etc. may be annotated with `@Nullable`
132+
- A package can be excluded (temporarily) using `@NullUnmarked`
133+
123134
### Tests
124135

125136
#### Naming

gradle/plugins/common/src/main/kotlin/junitbuild.java-nullability-conventions.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies {
1313
}
1414

1515
nullaway {
16-
onlyNullMarked = true
16+
annotatedPackages.add("org.junit")
1717
}
1818

1919
tasks.withType<JavaCompile>().configureEach {

junit-platform-commons/src/main/java/module-info.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,14 @@
88
* https://www.eclipse.org/legal/epl-v20.html
99
*/
1010

11+
import org.jspecify.annotations.NullMarked;
12+
1113
/**
1214
* Common APIs and support utilities for the JUnit Platform.
1315
*
1416
* @since 1.0
1517
*/
18+
@NullMarked
1619
module org.junit.platform.commons {
1720
requires java.logging;
1821
requires java.management; // needed by RuntimeUtils to determine input arguments

junit-platform-commons/src/main/java/org/junit/platform/commons/annotation/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Common annotations for the JUnit Platform.
33
*/
44

5-
@NullMarked
65
package org.junit.platform.commons.annotation;
7-
8-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/function/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Functional interfaces and support classes.
33
*/
44

5-
@NullMarked
65
package org.junit.platform.commons.function;
7-
8-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/logging/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@
88
* Use at your own risk!
99
*/
1010

11-
@NullMarked
1211
package org.junit.platform.commons.logging;
13-
14-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@
88
* APIs by external parties is not supported!</strong>
99
*/
1010

11-
@NullMarked
1211
package org.junit.platform.commons;
13-
14-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/support/conversion/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Conversion APIs provided by the JUnit Platform.
33
*/
44

5-
@NullMarked
65
package org.junit.platform.commons.support.conversion;
7-
8-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/support/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,4 @@
88
* extensions with the same semantics as within the JUnit Platform itself.
99
*/
1010

11-
@NullMarked
1211
package org.junit.platform.commons.support;
13-
14-
import org.jspecify.annotations.NullMarked;

junit-platform-commons/src/main/java/org/junit/platform/commons/support/scanning/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Classpath scanning APIs provided by the JUnit Platform.
33
*/
44

5-
@NullMarked
65
package org.junit.platform.commons.support.scanning;
7-
8-
import org.jspecify.annotations.NullMarked;

0 commit comments

Comments
 (0)