Skip to content

Commit

Permalink
Leverage @NullMarked instead of package configuration
Browse files Browse the repository at this point in the history
This commit replaces NullAway package configuration by package-level
`@NullMarked` detection by configuring `NullAway:AnnotatedPackages` to
an empty string.

NullAway configuration should be refined to use a proper flag instead
once uber/NullAway#574 is fixed.

See gh-28797
  • Loading branch information
sdeleuze committed Dec 23, 2024
1 parent 528578d commit 1e0ef99
Show file tree
Hide file tree
Showing 8 changed files with 4 additions and 22 deletions.
6 changes: 2 additions & 4 deletions gradle/spring-module.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,8 @@ tasks.withType(JavaCompile).configureEach {
options.errorprone {
disableAllChecks = true
option("NullAway:CustomContractAnnotations", "org.springframework.lang.Contract")
option("NullAway:AnnotatedPackages", "org.springframework")
option("NullAway:UnannotatedSubPackages", "org.springframework.instrument,org.springframework.context.index," +
"org.springframework.asm,org.springframework.cglib,org.springframework.objenesis," +
"org.springframework.javapoet,org.springframework.aot.nativex.substitution,org.springframework.aot.nativex.feature")
// TODO Replace by proper flag when supported, see https://github.com/uber/NullAway/issues/574
option("NullAway:AnnotatedPackages", "")
}
}
tasks.compileJava {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* Support for class instrumentation on GlassFish.
*/
@NullMarked
package org.springframework.instrument.classloading.glassfish;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* Support for class instrumentation on JBoss AS 6 and 7.
*/
@NullMarked
package org.springframework.instrument.classloading.jboss;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
* Support package for load time weaving based on class loaders,
* as required by JPA providers (but not JPA-specific).
*/
@NullMarked
package org.springframework.instrument.classloading;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* Support for class instrumentation on Tomcat.
*/
@NullMarked
package org.springframework.instrument.classloading.tomcat;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* GraalVM native image features, not part of Spring Framework public API.
*/
@NullMarked
package org.springframework.aot.nativex.feature;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
/**
* GraalVM native image substitutions, not part of Spring Framework public API.
*/
@NullMarked
package org.springframework.aot.nativex.substitution;

import org.jspecify.annotations.NullMarked;
2 changes: 2 additions & 0 deletions src/checkstyle/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@
<suppress files="RootBeanDefinition" checks="EqualsHashCode"/>

<!-- spring-context -->
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]instrument[\\/]" checks="RegexpSinglelineJava" id="packageLevelNullMarkedAnnotation"/>
<suppress files="SpringAtInjectTckTests" checks="IllegalImportCheck" id="bannedJUnit3Imports"/>

<!-- spring-core -->
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/](asm|cglib|objenesis|javapoet)[\\/]" checks=".*"/>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]aot[\\/]nativex[\\/]" checks="RegexpSinglelineJava" id="packageLevelNullMarkedAnnotation"/>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]aot[\\/]nativex[\\/]feature[\\/]" checks="RegexpSinglelineJava" id="systemOutErrPrint"/>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/](core|util)[\\/](SpringProperties|SystemPropertyUtils)" checks="RegexpSinglelineJava" id="systemOutErrPrint"/>
<suppress files="[\\/]src[\\/]main[\\/]java[\\/]org[\\/]springframework[\\/]lang[\\/]" checks="IllegalImport" id="bannedImports" message="javax"/>
Expand Down

0 comments on commit 1e0ef99

Please sign in to comment.