diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java index 254c2d04fbbf62..15826b99b5d06d 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigBuildStep.java @@ -27,10 +27,6 @@ import java.util.function.Supplier; import java.util.stream.Stream; -import jakarta.enterprise.context.Dependent; -import jakarta.enterprise.inject.CreationException; - -import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigValue; import org.eclipse.microprofile.config.inject.ConfigProperties; import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -42,10 +38,8 @@ import org.jboss.jandex.DotName; import org.jboss.jandex.FieldInfo; import org.jboss.jandex.MethodInfo; -import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; import org.jboss.jandex.Type.Kind; -import org.jboss.logging.Logger; import io.quarkus.arc.Unremovable; import io.quarkus.arc.deployment.BeanRegistrationPhaseBuildItem.BeanConfiguratorBuildItem; @@ -67,7 +61,6 @@ import io.quarkus.deployment.builditem.ConfigPropertiesBuildItem; import io.quarkus.deployment.builditem.ConfigurationBuildItem; import io.quarkus.deployment.builditem.GeneratedClassBuildItem; -import io.quarkus.deployment.builditem.RunTimeConfigurationDefaultBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; import io.quarkus.deployment.configuration.definition.RootDefinition; import io.quarkus.deployment.pkg.PackageConfig; @@ -76,19 +69,18 @@ import io.quarkus.runtime.annotations.ConfigPhase; import io.smallrye.config.ConfigMappings.ConfigClassWithPrefix; import io.smallrye.config.inject.ConfigProducer; +import jakarta.enterprise.context.Dependent; +import jakarta.enterprise.inject.CreationException; /** * MicroProfile Config related build steps. */ public class ConfigBuildStep { - private static final Logger LOGGER = Logger.getLogger(ConfigBuildStep.class.getName()); - - private static final DotName MP_CONFIG = DotName.createSimple(Config.class.getName()); + static final DotName MP_CONFIG_PROPERTY_NAME = DotName.createSimple(ConfigProperty.class.getName()); private static final DotName MP_CONFIG_PROPERTIES_NAME = DotName.createSimple(ConfigProperties.class.getName()); private static final DotName MP_CONFIG_VALUE_NAME = DotName.createSimple(ConfigValue.class.getName()); - private static final DotName SR_CONFIG = DotName.createSimple(io.smallrye.config.SmallRyeConfig.class.getName()); private static final DotName SR_CONFIG_VALUE_NAME = DotName.createSimple(io.smallrye.config.ConfigValue.class.getName()); private static final DotName MAP_NAME = DotName.createSimple(Map.class.getName()); @@ -480,67 +472,6 @@ void validateConfigPropertiesInjectionPoints( toRegister.forEach(configProperties::produce); } - @BuildStep - void warnStaticInitInjectionPoints( - CombinedIndexBuildItem indexBuildItem, - ValidationPhaseBuildItem validationPhase, - List<ConfigClassBuildItem> configClasses, - List<ConfigInjectionStaticInitBuildItem> configInjectionStaticInit, - BuildProducer<RunTimeConfigurationDefaultBuildItem> runTimeConfigurationDefault) { - - // Add here annotated classes that are initialized during static init - Set<DotName> declaringClassCandidates = configInjectionStaticInit.stream() - .map(ConfigInjectionStaticInitBuildItem::getDeclaringCandidate).collect(toSet()); - - Set<Type> configClassesTypes = configClasses.stream().map(ConfigClassBuildItem::getTypes).flatMap(Collection::stream) - .collect(toSet()); - - for (InjectionPointInfo injectionPoint : validationPhase.getContext().getInjectionPoints()) { - if (injectionPoint.getType().name().equals(DotNames.INSTANCE)) { - continue; - } - - Type type = Type.create(injectionPoint.getRequiredType().name(), Type.Kind.CLASS); - DotName injectionTypeName = null; - if (type.name().equals(MP_CONFIG) || type.name().equals(SR_CONFIG)) { - injectionTypeName = type.name(); - } else if (injectionPoint.getRequiredQualifier(MP_CONFIG_PROPERTY_NAME) != null) { - injectionTypeName = MP_CONFIG_PROPERTY_NAME; - } else if (configClassesTypes.contains(type)) { - injectionTypeName = type.name(); - } - - if (injectionTypeName != null) { - AnnotationTarget target = injectionPoint.getTarget(); - if (FIELD.equals(target.kind())) { - FieldInfo field = target.asField(); - ClassInfo declaringClass = field.declaringClass(); - Map<DotName, List<AnnotationInstance>> annotationsMap = declaringClass.annotationsMap(); - for (DotName declaringClassCandidate : declaringClassCandidates) { - List<AnnotationInstance> annotationInstances = annotationsMap.get(declaringClassCandidate); - if (annotationInstances != null && annotationInstances.size() == 1) { - AnnotationInstance annotationInstance = annotationInstances.get(0); - if (annotationInstance.target().equals(declaringClass)) { - LOGGER.warn("Directly injecting a " + - injectionTypeName + - " into a " + - declaringClassCandidate + - " may lead to unexpected results. To ensure proper results, please " + - "change the type of the field to " + - ParameterizedType.create(DotNames.INSTANCE, new Type[] { type }, null) + - ". Offending field is '" + - field.name() + - "' of class '" + - field.declaringClass() + - "'"); - } - } - } - } - } - } - } - @BuildStep @Record(RUNTIME_INIT) void registerConfigClasses( diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java index d3674722fa64b6..9582c46fbbd5b7 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ConfigInjectionStaticInitBuildItem.java @@ -6,7 +6,7 @@ /** * - * @deprecated TODO + * @deprecated This build item is not used anymore */ @Deprecated(forRemoval = true) public final class ConfigInjectionStaticInitBuildItem extends MultiBuildItem { diff --git a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java index de8247f62696b0..1dc03909ab9f69 100644 --- a/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java +++ b/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java @@ -12,14 +12,6 @@ import java.util.function.Function; import java.util.stream.Collectors; -import jakarta.ws.rs.Consumes; -import jakarta.ws.rs.Produces; -import jakarta.ws.rs.core.MediaType; -import jakarta.ws.rs.ext.ContextResolver; -import jakarta.ws.rs.ext.MessageBodyReader; -import jakarta.ws.rs.ext.MessageBodyWriter; -import jakarta.ws.rs.ext.Providers; - import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationValue; @@ -43,7 +35,6 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.BeanArchiveIndexBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; -import io.quarkus.arc.deployment.ConfigInjectionStaticInitBuildItem; import io.quarkus.arc.deployment.UnremovableBeanBuildItem; import io.quarkus.arc.processor.DotNames; import io.quarkus.deployment.Capabilities; @@ -70,6 +61,13 @@ import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigRoot; import io.quarkus.runtime.configuration.MemorySize; +import jakarta.ws.rs.Consumes; +import jakarta.ws.rs.Produces; +import jakarta.ws.rs.core.MediaType; +import jakarta.ws.rs.ext.ContextResolver; +import jakarta.ws.rs.ext.MessageBodyReader; +import jakarta.ws.rs.ext.MessageBodyWriter; +import jakarta.ws.rs.ext.Providers; public class ResteasyCommonProcessor { @@ -181,11 +179,6 @@ ResteasyInjectionReadyBuildItem setupResteasyInjection( return new ResteasyInjectionReadyBuildItem(injectorFactory); } - @BuildStep - ConfigInjectionStaticInitBuildItem configInjectionStaticInitProvider() { - return new ConfigInjectionStaticInitBuildItem(ResteasyDotNames.PROVIDER); - } - @BuildStep JaxrsProvidersToRegisterBuildItem setupProviders(BuildProducer<ReflectiveClassBuildItem> reflectiveClass, CombinedIndexBuildItem indexBuildItem, diff --git a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java index 06fd8dd5d71698..4b7e760e719be0 100644 --- a/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java +++ b/extensions/undertow/deployment/src/main/java/io/quarkus/undertow/deployment/UndertowBuildStep.java @@ -18,22 +18,6 @@ import java.util.function.Consumer; import java.util.stream.Collectors; -import jakarta.annotation.security.DeclareRoles; -import jakarta.annotation.security.RunAs; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.enterprise.context.SessionScoped; -import jakarta.enterprise.inject.Typed; -import jakarta.inject.Inject; -import jakarta.servlet.ServletContainerInitializer; -import jakarta.servlet.ServletContext; -import jakarta.servlet.SessionTrackingMode; -import jakarta.servlet.annotation.HandlesTypes; -import jakarta.servlet.annotation.MultipartConfig; -import jakarta.servlet.annotation.ServletSecurity; -import jakarta.servlet.annotation.WebFilter; -import jakarta.servlet.annotation.WebListener; -import jakarta.servlet.annotation.WebServlet; - import org.jboss.annotation.javaee.Descriptions; import org.jboss.annotation.javaee.DisplayNames; import org.jboss.annotation.javaee.Icons; @@ -81,7 +65,6 @@ import io.quarkus.arc.deployment.AdditionalBeanBuildItem; import io.quarkus.arc.deployment.AnnotationsTransformerBuildItem; import io.quarkus.arc.deployment.BeanContainerBuildItem; -import io.quarkus.arc.deployment.ConfigInjectionStaticInitBuildItem; import io.quarkus.arc.deployment.ContextRegistrationPhaseBuildItem; import io.quarkus.arc.deployment.ContextRegistrationPhaseBuildItem.ContextConfiguratorBuildItem; import io.quarkus.arc.deployment.CustomScopeBuildItem; @@ -134,6 +117,21 @@ import io.undertow.servlet.handlers.DefaultServlet; import io.vertx.core.Handler; import io.vertx.ext.web.RoutingContext; +import jakarta.annotation.security.DeclareRoles; +import jakarta.annotation.security.RunAs; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.context.SessionScoped; +import jakarta.enterprise.inject.Typed; +import jakarta.inject.Inject; +import jakarta.servlet.ServletContainerInitializer; +import jakarta.servlet.ServletContext; +import jakarta.servlet.SessionTrackingMode; +import jakarta.servlet.annotation.HandlesTypes; +import jakarta.servlet.annotation.MultipartConfig; +import jakarta.servlet.annotation.ServletSecurity; +import jakarta.servlet.annotation.WebFilter; +import jakarta.servlet.annotation.WebListener; +import jakarta.servlet.annotation.WebServlet; //TODO: break this up, it is getting too big public class UndertowBuildStep { @@ -685,11 +683,6 @@ SyntheticBeanBuildItem servletContextBean( .supplier(recorder.servletContextSupplier()).done(); } - @BuildStep - ConfigInjectionStaticInitBuildItem configInjectionStaticInitAnnotations() { - return new ConfigInjectionStaticInitBuildItem(WEB_FILTER); - } - /** * Process a single index. *