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;

junit-platform-commons/src/main/java/org/junit/platform/commons/util/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.util;
13-
14-
import org.jspecify.annotations.NullMarked;

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

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

11+
import org.jspecify.annotations.NullMarked;
12+
1113
/**
1214
* Public API for test engines.
1315
*
@@ -16,6 +18,7 @@
1618
*
1719
* @since 1.0
1820
*/
21+
@NullMarked
1922
module org.junit.platform.engine {
2023

2124
requires static transitive org.apiguardian.api;

junit-platform-engine/src/main/java/org/junit/platform/engine/discovery/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
* {@linkplain org.junit.platform.engine.EngineDiscoveryRequest discovery requests}.
55
*/
66

7-
@NullMarked
87
package org.junit.platform.engine.discovery;
9-
10-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Public API for test engines.
33
*/
44

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

junit-platform-engine/src/main/java/org/junit/platform/engine/reporting/package-info.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@
33
* listeners.
44
*/
55

6-
@NullMarked
76
package org.junit.platform.engine.reporting;
8-
9-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,4 @@
33
* classes intended to be used by test engine implementations.
44
*/
55

6-
@NullMarked
76
package org.junit.platform.engine.support.config;
8-
9-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,4 @@
44
* the launcher.
55
*/
66

7-
@NullMarked
87
package org.junit.platform.engine.support.descriptor;
9-
10-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@
66
* @see org.junit.platform.engine.support.discovery.SelectorResolver
77
*/
88

9-
@NullMarked
109
package org.junit.platform.engine.support.discovery;
11-
12-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,4 @@
55
* {@link org.junit.platform.engine.support.hierarchical.Node} abstraction.
66
*/
77

8-
@NullMarked
98
package org.junit.platform.engine.support.hierarchical;
10-
11-
import org.jspecify.annotations.NullMarked;

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,4 @@
22
* Reusable data structures for test engines and their extensions.
33
*/
44

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

0 commit comments

Comments
 (0)