Leverage `@NullMarked` instead of package configuration

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
This commit is contained in:
Sébastien Deleuze 2024-12-23 17:14:29 +01:00
parent 528578d138
commit 1e0ef99b0c
8 changed files with 4 additions and 22 deletions

View File

@ -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 {

View File

@ -1,7 +1,4 @@
/**
* Support for class instrumentation on GlassFish.
*/
@NullMarked
package org.springframework.instrument.classloading.glassfish;
import org.jspecify.annotations.NullMarked;

View File

@ -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;

View File

@ -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;

View File

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

View File

@ -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;

View File

@ -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;

View File

@ -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"/>