Skip to content

Commit 8bbb16d

Browse files
committed
GH-1192 - Migrate code base to jSpecify for nullness verification.
1 parent 66c8dac commit 8bbb16d

File tree

134 files changed

+548
-211
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+548
-211
lines changed

.github/workflows/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ jobs:
3131
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
3232
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }}
3333
DEVELOCITY_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_SECRET_ACCESS_KEY }}
34-
run: ./mvnw -B clean deploy -Pci,artifactory
34+
run: ./mvnw -B clean deploy -Pci,artifactory,nullaway

.mvn/jvm.config

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
7+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
8+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
9+
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
10+
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED

pom.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@
3737

3838
<archunit.version>1.4.0</archunit.version>
3939
<artifactory-maven-plugin.version>3.6.2</artifactory-maven-plugin.version>
40+
<errorprone.version>2.36.0</errorprone.version>
4041
<flapdoodle-mongodb.version>4.16.1</flapdoodle-mongodb.version>
4142
<jgit.version>7.0.0.202409031743-r</jgit.version>
4243
<jgrapht.version>1.5.2</jgrapht.version>
4344
<jmolecules-bom.version>2023.3.1</jmolecules-bom.version>
45+
<nullaway.version>0.12.7</nullaway.version>
4446
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
4547
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4648
<spring-boot.version>4.0.0-SNAPSHOT</spring-boot.version>
@@ -431,6 +433,54 @@ limitations under the License.
431433
</build>
432434
</profile>
433435

436+
<profile>
437+
<id>nullaway</id>
438+
<build>
439+
<plugins>
440+
<plugin>
441+
<groupId>org.apache.maven.plugins</groupId>
442+
<artifactId>maven-compiler-plugin</artifactId>
443+
<configuration>
444+
<showWarnings>true</showWarnings>
445+
446+
</configuration>
447+
<executions>
448+
<execution>
449+
<id>default-compile</id>
450+
<phase>none</phase>
451+
</execution>
452+
<execution>
453+
<id>java-compile</id>
454+
<phase>compile</phase>
455+
<goals>
456+
<goal>compile</goal>
457+
</goals>
458+
<configuration>
459+
<annotationProcessorPaths>
460+
<path>
461+
<groupId>com.google.errorprone</groupId>
462+
<artifactId>error_prone_core</artifactId>
463+
<version>${errorprone.version}</version>
464+
</path>
465+
<path>
466+
<groupId>com.uber.nullaway</groupId>
467+
<artifactId>nullaway</artifactId>
468+
<version>${nullaway.version}</version>
469+
</path>
470+
</annotationProcessorPaths>
471+
<compilerArgs>
472+
<arg>-XDcompilePolicy=simple</arg>
473+
<arg>--should-stop=ifError=FLOW</arg>
474+
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract</arg>
475+
</compilerArgs>
476+
</configuration>
477+
</execution>
478+
</executions>
479+
</plugin>
480+
</plugins>
481+
</build>
482+
</profile>
483+
434484
</profiles>
435485

436486
<dependencies>

spring-modulith-actuator/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616

1717
<dependencies>
1818

19+
<dependency>
20+
<groupId>org.jspecify</groupId>
21+
<artifactId>jspecify</artifactId>
22+
</dependency>
23+
1924
<dependency>
2025
<groupId>org.springframework.modulith</groupId>
2126
<artifactId>spring-modulith-runtime</artifactId>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* Autoconfiguration for Spring Modulith actuators.
33
*/
4-
@org.springframework.lang.NonNullApi
4+
@org.jspecify.annotations.NullMarked
55
package org.springframework.modulith.actuator.autoconfigure;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* Spring Boot actuator support for Spring Modulith.
33
*/
4-
@org.springframework.lang.NonNullApi
4+
@org.jspecify.annotations.NullMarked
55
package org.springframework.modulith.actuator;

spring-modulith-api/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717

1818
<dependencies>
1919

20+
<dependency>
21+
<groupId>org.jspecify</groupId>
22+
<artifactId>jspecify</artifactId>
23+
</dependency>
24+
2025
<dependency>
2126
<groupId>org.springframework.boot</groupId>
2227
<artifactId>spring-boot-autoconfigure</artifactId>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
22
* Core abstractions of Spring Modulith. To be referred to in user applications.
33
*/
4-
@org.springframework.lang.NonNullApi
4+
@org.jspecify.annotations.NullMarked
55
package org.springframework.modulith;

spring-modulith-apt/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
<artifactId>aptk-tools</artifactId>
2222
<version>0.29.0</version>
2323
</dependency>
24+
<dependency>
25+
<groupId>org.jspecify</groupId>
26+
<artifactId>jspecify</artifactId>
27+
</dependency>
2428

2529
<dependency>
2630
<groupId>org.springframework.boot</groupId>

spring-modulith-apt/src/main/java/org/springframework/modulith/apt/SpringModulithProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io.toolisticon.aptk.tools.wrapper.ElementWrapper;
2020
import io.toolisticon.aptk.tools.wrapper.ExecutableElementWrapper;
2121
import io.toolisticon.aptk.tools.wrapper.TypeElementWrapper;
22+
import org.jspecify.annotations.Nullable;
2223

2324
import java.io.File;
2425
import java.io.FileWriter;
@@ -50,7 +51,6 @@
5051
import javax.tools.StandardLocation;
5152

5253
import org.springframework.boot.json.JsonWriter;
53-
import org.springframework.lang.Nullable;
5454
import org.springframework.modulith.docs.metadata.MethodMetadata;
5555
import org.springframework.modulith.docs.metadata.TypeMetadata;
5656
import org.springframework.modulith.docs.util.BuildSystemUtils;

0 commit comments

Comments
 (0)