diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java index 7966aa72d226d..ee380f9ee742e 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java @@ -798,19 +798,6 @@ private void registerUnremovableListBeans(BeanRegistrationPhaseBuildItem beanReg BuildProducer reflectiveFields, BuildProducer unremovableBeans) { BeanDeployment beanDeployment = beanRegistrationPhase.getBeanProcessor().getBeanDeployment(); - ReflectionRegistration reflectionRegistration = new ReflectionRegistration() { - @Override - public void registerMethod(MethodInfo methodInfo) { - reflectiveMethods.produce(new ReflectiveMethodBuildItem(methodInfo)); - } - - @Override - public void registerField(FieldInfo fieldInfo) { - reflectiveFields.produce(new ReflectiveFieldBuildItem(fieldInfo)); - } - - }; - List unremovables = new ArrayList<>(); for (InjectionPointInfo injectionPoint : injectionPoints) { diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionInvoker.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionInvoker.java index a8bf31dbc691e..a2e940cbe2216 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionInvoker.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionInvoker.java @@ -134,4 +134,12 @@ void invalidate() { extensionClasses.clear(); extensionClassInstances.clear(); } + + /** + * + * @return {@code true} if no {@link BuildCompatibleExtension} was found, {@code false} otherwise + */ + boolean isEmpty() { + return extensionClasses.isEmpty(); + } } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionsEntryPoint.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionsEntryPoint.java index 0cd4301925ede..8e1bee97b96da 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionsEntryPoint.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/bcextensions/ExtensionsEntryPoint.java @@ -69,18 +69,18 @@ */ public class ExtensionsEntryPoint { private final ExtensionInvoker invoker; - private final AllAnnotationOverlays annotationOverlays = new AllAnnotationOverlays(); - private final SharedErrors errors = new SharedErrors(); + private final AllAnnotationOverlays annotationOverlays; + private final SharedErrors errors; - private final Map qualifiers = new ConcurrentHashMap<>(); - private final Map interceptorBindings = new ConcurrentHashMap<>(); - private final Map stereotypes = new ConcurrentHashMap<>(); - private final List contexts = Collections.synchronizedList(new ArrayList<>()); + private final Map qualifiers; + private final Map interceptorBindings; + private final Map stereotypes; + private final List contexts; private volatile AllAnnotationTransformations preAnnotationTransformations; - private final List> syntheticBeans = Collections.synchronizedList(new ArrayList<>()); - private final List> syntheticObservers = Collections.synchronizedList(new ArrayList<>()); + private final List> syntheticBeans; + private final List> syntheticObservers; public ExtensionsEntryPoint() { this(List.of()); @@ -88,13 +88,37 @@ public ExtensionsEntryPoint() { // only for `ArcTestContainer` public ExtensionsEntryPoint(List extensions) { - this.invoker = new ExtensionInvoker(extensions); + invoker = new ExtensionInvoker(extensions); + if (invoker.isEmpty()) { + annotationOverlays = null; + errors = null; + qualifiers = null; + interceptorBindings = null; + stereotypes = null; + contexts = null; + syntheticBeans = null; + syntheticObservers = null; + } else { + annotationOverlays = new AllAnnotationOverlays(); + errors = new SharedErrors(); + qualifiers = new ConcurrentHashMap<>(); + interceptorBindings = new ConcurrentHashMap<>(); + stereotypes = new ConcurrentHashMap<>(); + contexts = Collections.synchronizedList(new ArrayList<>()); + syntheticBeans = Collections.synchronizedList(new ArrayList<>()); + syntheticObservers = Collections.synchronizedList(new ArrayList<>()); + } } /** * Must be called first, before {@code registerMetaAnnotations}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runDiscovery(org.jboss.jandex.IndexView applicationIndex, Set additionalClasses) { + if (invoker.isEmpty()) { + return; + } try { BuildServicesImpl.init(applicationIndex, annotationOverlays); @@ -117,8 +141,13 @@ public void runDiscovery(org.jboss.jandex.IndexView applicationIndex, Setafter {@code runDiscovery} and before {@code runEnhancement}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void registerMetaAnnotations(BeanProcessor.Builder builder) { + if (invoker.isEmpty()) { + return; + } builder.addAnnotationTransformer(preAnnotationTransformations.classes); builder.addAnnotationTransformer(preAnnotationTransformations.methods); builder.addAnnotationTransformer(preAnnotationTransformations.parameters); @@ -200,8 +229,13 @@ public void register(RegistrationContext registrationContext) { /** * Must be called after {@code registerMetaAnnotations} and before {@code runRegistration}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runEnhancement(org.jboss.jandex.IndexView beanArchiveIndex, BeanProcessor.Builder builder) { + if (invoker.isEmpty()) { + return; + } AllAnnotationTransformations annotationTransformations = new AllAnnotationTransformations(beanArchiveIndex, annotationOverlays); builder.addAnnotationTransformer(annotationTransformations.classes); @@ -223,10 +257,15 @@ public void runEnhancement(org.jboss.jandex.IndexView beanArchiveIndex, BeanProc /** * Must be called after {@code runEnhancement} and before {@code runSynthesis}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runRegistration(org.jboss.jandex.IndexView beanArchiveIndex, Collection allBeans, Collection allObservers) { + if (invoker.isEmpty()) { + return; + } BuildServicesImpl.init(beanArchiveIndex, annotationOverlays); @@ -240,8 +279,14 @@ public void runRegistration(org.jboss.jandex.IndexView beanArchiveIndex, /** * Must be called after {@code runRegistration} and before {@code registerSyntheticBeans}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runSynthesis(org.jboss.jandex.IndexView beanArchiveIndex) { + if (invoker.isEmpty()) { + return; + } + BuildServicesImpl.init(beanArchiveIndex, annotationOverlays); try { @@ -254,8 +299,14 @@ public void runSynthesis(org.jboss.jandex.IndexView beanArchiveIndex) { /** * Must be called after {@code runSynthesis} and before {@code runRegistrationAgain}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void registerSyntheticBeans(BeanRegistrar.RegistrationContext context) { + if (invoker.isEmpty()) { + return; + } + Map allStereotypes = context.get(BuildExtension.Key.STEREOTYPES); for (SyntheticBeanBuilderImpl syntheticBean : syntheticBeans) { @@ -369,8 +420,14 @@ public void registerSyntheticBeans(BeanRegistrar.RegistrationContext context) { /** * Must be called after {@code runSynthesis} and before {@code runRegistrationAgain}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void registerSyntheticObservers(ObserverRegistrar.RegistrationContext context) { + if (invoker.isEmpty()) { + return; + } + for (SyntheticObserverBuilderImpl syntheticObserver : syntheticObservers) { if (syntheticObserver.isAsync && syntheticObserver.transactionPhase != TransactionPhase.IN_PROGRESS) { throw new IllegalStateException("Synthetic observer declared as asynchronous and transactional " @@ -475,10 +532,16 @@ private void configureParams(ConfiguratorBase configurator, Mapafter {@code registerSynthetic{Beans,Observers}} and before * {@code runValidation}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runRegistrationAgain(org.jboss.jandex.IndexView beanArchiveIndex, Collection allBeans, Collection allObservers) { + if (invoker.isEmpty()) { + return; + } + Collection syntheticBeans = allBeans.stream() .filter(BeanInfo::isSynthetic) .collect(Collectors.toUnmodifiableList()); @@ -498,10 +561,15 @@ public void runRegistrationAgain(org.jboss.jandex.IndexView beanArchiveIndex, /** * Must be called after {@code runRegistrationAgain} and before {@code registerValidationErrors}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void runValidation(org.jboss.jandex.IndexView beanArchiveIndex, Collection allBeans, Collection allObservers) { + if (invoker.isEmpty()) { + return; + } BuildServicesImpl.init(beanArchiveIndex, annotationOverlays); @@ -515,8 +583,14 @@ public void runValidation(org.jboss.jandex.IndexView beanArchiveIndex, /** * Must be called last, after {@code runValidation}. + *

+ * It is a no-op if no {@link BuildCompatibleExtension} was found. */ public void registerValidationErrors(BeanDeploymentValidator.ValidationContext context) { + if (invoker.isEmpty()) { + return; + } + for (Throwable error : errors.list) { context.addDeploymentProblem(error); }