diff --git a/.mvn/jvm.config b/.mvn/jvm.config new file mode 100644 index 0000000..32599ce --- /dev/null +++ b/.mvn/jvm.config @@ -0,0 +1,10 @@ +--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED +--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED +--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED diff --git a/core/src/main/java/org/springframework/plugin/core/config/PluginRegistriesBeanDefinitionRegistrar.java b/core/src/main/java/org/springframework/plugin/core/config/PluginRegistriesBeanDefinitionRegistrar.java index 43e3741..2876549 100644 --- a/core/src/main/java/org/springframework/plugin/core/config/PluginRegistriesBeanDefinitionRegistrar.java +++ b/core/src/main/java/org/springframework/plugin/core/config/PluginRegistriesBeanDefinitionRegistrar.java @@ -17,6 +17,7 @@ package org.springframework.plugin.core.config; import java.util.Map; +import org.jspecify.annotations.Nullable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Qualifier; @@ -58,8 +59,13 @@ public class PluginRegistriesBeanDefinitionRegistrar implements ImportBeanDefini return; } + @Nullable Class[] types = (Class[]) annotationAttributes.get("value"); + if (types == null) { + return; + } + for (Class type : types) { RootBeanDefinition beanDefinition = new RootBeanDefinition(PluginRegistryFactoryBean.class); diff --git a/core/src/main/java/org/springframework/plugin/core/config/package-info.java b/core/src/main/java/org/springframework/plugin/core/config/package-info.java index 4d50322..867f261 100644 --- a/core/src/main/java/org/springframework/plugin/core/config/package-info.java +++ b/core/src/main/java/org/springframework/plugin/core/config/package-info.java @@ -1,5 +1,5 @@ /** * This package contains configuration support classes to ease registry configuration with Spring namespaces. */ +@org.jspecify.annotations.NullMarked package org.springframework.plugin.core.config; - diff --git a/core/src/main/java/org/springframework/plugin/core/package-info.java b/core/src/main/java/org/springframework/plugin/core/package-info.java index 4aa38c0..8b5fadb 100644 --- a/core/src/main/java/org/springframework/plugin/core/package-info.java +++ b/core/src/main/java/org/springframework/plugin/core/package-info.java @@ -2,5 +2,5 @@ * This package contains the core plugin API. It allows other modules implementing components that extend functionality * defined by a plugin interface. Plugin clients can be equipped with plugin implementations. */ -@org.springframework.lang.NonNullApi +@org.jspecify.annotations.NullMarked package org.springframework.plugin.core; diff --git a/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java b/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java index fcdd934..7cbacb5 100644 --- a/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java +++ b/core/src/main/java/org/springframework/plugin/core/support/PluginRegistryFactoryBean.java @@ -22,6 +22,8 @@ import java.util.List; import java.util.function.Predicate; import java.util.function.Supplier; +import org.jspecify.annotations.NonNull; +import org.jspecify.annotations.Nullable; import org.springframework.beans.BeansException; import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactoryAware; @@ -30,8 +32,6 @@ import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.ListableBeanFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; -import org.springframework.lang.NonNull; -import org.springframework.lang.Nullable; import org.springframework.plugin.core.OrderAwarePluginRegistry; import org.springframework.plugin.core.Plugin; import org.springframework.plugin.core.PluginRegistry; @@ -46,7 +46,7 @@ public class PluginRegistryFactoryBean, S> private Collection> exclusions = Collections.emptySet(); private @Nullable Class type; - private ListableBeanFactory factory; + private @Nullable ListableBeanFactory factory; /** * Configures the type of beans to be looked up. @@ -103,6 +103,12 @@ public class PluginRegistryFactoryBean, S> throw new IllegalStateException("No plugin type configured!"); } + var factory = this.factory; + + if (factory == null) { + throw new IllegalStateException("No ListableBeanFactory configured!"); + } + Supplier> plugins = () -> factory.getBeanProvider(type, false) .stream(Predicate.not(exclusions::contains)) .toList(); diff --git a/core/src/main/java/org/springframework/plugin/core/support/package-info.java b/core/src/main/java/org/springframework/plugin/core/support/package-info.java index b92954d..7174d7f 100644 --- a/core/src/main/java/org/springframework/plugin/core/support/package-info.java +++ b/core/src/main/java/org/springframework/plugin/core/support/package-info.java @@ -2,5 +2,5 @@ * This package contains support classes to create bean lists or plugin registry instances out of beans implementing a * certain interface. */ -@org.springframework.lang.NonNullApi +@org.jspecify.annotations.NullMarked package org.springframework.plugin.core.support; diff --git a/pom.xml b/pom.xml index a258ba1..6a62d3f 100644 --- a/pom.xml +++ b/pom.xml @@ -46,10 +46,13 @@ UTF-8 3.23.1 + 2.36.0 5.9.1 1.4.4 4.9.0 + 0.12.3 7.0.0-SNAPSHOT + 17 2.0.3 3.4.0 @@ -187,6 +190,65 @@ + + nullaway + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${source.level} + true + + + com.google.errorprone + error_prone_core + ${errorprone.version} + + + com.uber.nullaway + nullaway + ${nullaway.version} + + + + + + default-compile + none + + + default-testCompile + none + + + java-compile + compile + + compile + + + + -XDcompilePolicy=simple + --should-stop=ifError=FLOW + -Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR -XepOpt:NullAway:OnlyNullMarked=true -XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract + + + + + java-test-compile + test-compile + + testCompile + + + + + + + + @@ -228,6 +290,12 @@ ${slf4j.version} + + org.jspecify + jspecify + 1.0.0 + + org.slf4j jcl-over-slf4j