|
1 | 1 | package io.quarkus.arc.deployment; |
2 | 2 |
|
3 | | -import static io.quarkus.arc.processor.KotlinUtils.isKotlinClass; |
4 | 3 | import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT; |
5 | 4 | import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT; |
6 | 5 |
|
|
9 | 8 | import java.util.Collection; |
10 | 9 | import java.util.HashMap; |
11 | 10 | import java.util.HashSet; |
12 | | -import java.util.Iterator; |
13 | 11 | import java.util.List; |
14 | 12 | import java.util.Map; |
15 | 13 | import java.util.Optional; |
|
23 | 21 | import jakarta.enterprise.context.ApplicationScoped; |
24 | 22 | import jakarta.enterprise.inject.AmbiguousResolutionException; |
25 | 23 | import jakarta.enterprise.inject.UnsatisfiedResolutionException; |
26 | | -import jakarta.enterprise.inject.spi.DefinitionException; |
27 | 24 |
|
28 | 25 | import org.jboss.jandex.AnnotationInstance; |
29 | 26 | import org.jboss.jandex.AnnotationTarget; |
30 | | -import org.jboss.jandex.AnnotationValue; |
31 | 27 | import org.jboss.jandex.ClassInfo; |
32 | 28 | import org.jboss.jandex.DotName; |
33 | 29 | import org.jboss.jandex.FieldInfo; |
|
46 | 42 | import io.quarkus.arc.deployment.UnremovableBeanBuildItem.BeanTypeExclusion; |
47 | 43 | import io.quarkus.arc.deployment.ValidationPhaseBuildItem.ValidationErrorBuildItem; |
48 | 44 | import io.quarkus.arc.processor.AlternativePriorities; |
49 | | -import io.quarkus.arc.processor.Annotations; |
50 | 45 | import io.quarkus.arc.processor.AnnotationsTransformer; |
51 | 46 | import io.quarkus.arc.processor.BeanConfigurator; |
52 | 47 | import io.quarkus.arc.processor.BeanDefiningAnnotation; |
|
56 | 51 | import io.quarkus.arc.processor.BeanProcessor; |
57 | 52 | import io.quarkus.arc.processor.BeanRegistrar; |
58 | 53 | import io.quarkus.arc.processor.BeanResolver; |
59 | | -import io.quarkus.arc.processor.Beans; |
60 | 54 | import io.quarkus.arc.processor.BytecodeTransformer; |
61 | 55 | import io.quarkus.arc.processor.ContextConfigurator; |
62 | 56 | import io.quarkus.arc.processor.ContextRegistrar; |
63 | 57 | import io.quarkus.arc.processor.DotNames; |
64 | | -import io.quarkus.arc.processor.InjectionPointInfo; |
65 | | -import io.quarkus.arc.processor.InjectionPointInfo.TypeAndQualifiers; |
66 | 58 | import io.quarkus.arc.processor.ObserverConfigurator; |
67 | 59 | import io.quarkus.arc.processor.ObserverRegistrar; |
68 | 60 | import io.quarkus.arc.processor.ReflectionRegistration; |
@@ -466,39 +458,6 @@ public ObserverRegistrationPhaseBuildItem registerSyntheticObservers(BeanRegistr |
466 | 458 | // Initialize the type -> bean map |
467 | 459 | beanRegistrationPhase.getBeanProcessor().getBeanDeployment().initBeanByTypeMap(); |
468 | 460 |
|
469 | | - // Register a synthetic bean for each List<?> with qualifier @All |
470 | | - List<InjectionPointInfo> listAll = beanRegistrationPhase.getInjectionPoints().stream() |
471 | | - .filter(this::isListAllInjectionPoint).collect(Collectors.toList()); |
472 | | - for (InjectionPointInfo injectionPoint : listAll) { |
473 | | - // Note that at this point we can be sure that the required type is List<> |
474 | | - Type typeParam = injectionPoint.getType().asParameterizedType().arguments().get(0); |
475 | | - if (typeParam.kind() == Type.Kind.WILDCARD_TYPE) { |
476 | | - ClassInfo declaringClass; |
477 | | - if (injectionPoint.isField()) { |
478 | | - declaringClass = injectionPoint.getTarget().asField().declaringClass(); |
479 | | - } else { |
480 | | - declaringClass = injectionPoint.getTarget().asMethod().declaringClass(); |
481 | | - } |
482 | | - if (isKotlinClass(declaringClass)) { |
483 | | - validationErrors.produce(new ValidationErrorBuildItem( |
484 | | - new DefinitionException( |
485 | | - "kotlin.collections.List cannot be used together with the @All qualifier, please use MutableList or java.util.List instead: " |
486 | | - + injectionPoint.getTargetInfo()))); |
487 | | - } else { |
488 | | - validationErrors.produce(new ValidationErrorBuildItem( |
489 | | - new DefinitionException( |
490 | | - "Wildcard is not a legal type argument for " + injectionPoint.getTargetInfo()))); |
491 | | - } |
492 | | - } else if (typeParam.kind() == Type.Kind.TYPE_VARIABLE) { |
493 | | - validationErrors.produce(new ValidationErrorBuildItem(new DefinitionException( |
494 | | - "Type variable is not a legal type argument for " + injectionPoint.getTargetInfo()))); |
495 | | - } |
496 | | - } |
497 | | - if (!listAll.isEmpty()) { |
498 | | - registerUnremovableListBeans(beanRegistrationPhase, listAll, reflectiveMethods, reflectiveFields, |
499 | | - unremovableBeans); |
500 | | - } |
501 | | - |
502 | 461 | BeanProcessor beanProcessor = beanRegistrationPhase.getBeanProcessor(); |
503 | 462 | ObserverRegistrar.RegistrationContext registrationContext = beanProcessor.registerSyntheticObservers(); |
504 | 463 |
|
@@ -793,60 +752,6 @@ void registerContextPropagation(ArcConfig config, BuildProducer<ThreadContextPro |
793 | 752 | } |
794 | 753 | } |
795 | 754 |
|
796 | | - private void registerUnremovableListBeans(BeanRegistrationPhaseBuildItem beanRegistrationPhase, |
797 | | - List<InjectionPointInfo> injectionPoints, BuildProducer<ReflectiveMethodBuildItem> reflectiveMethods, |
798 | | - BuildProducer<ReflectiveFieldBuildItem> reflectiveFields, |
799 | | - BuildProducer<UnremovableBeanBuildItem> unremovableBeans) { |
800 | | - BeanDeployment beanDeployment = beanRegistrationPhase.getBeanProcessor().getBeanDeployment(); |
801 | | - List<TypeAndQualifiers> unremovables = new ArrayList<>(); |
802 | | - |
803 | | - for (InjectionPointInfo injectionPoint : injectionPoints) { |
804 | | - // All qualifiers but @All |
805 | | - Set<AnnotationInstance> qualifiers = new HashSet<>(injectionPoint.getRequiredQualifiers()); |
806 | | - for (Iterator<AnnotationInstance> it = qualifiers.iterator(); it.hasNext();) { |
807 | | - AnnotationInstance qualifier = it.next(); |
808 | | - if (DotNames.ALL.equals(qualifier.name())) { |
809 | | - it.remove(); |
810 | | - } |
811 | | - } |
812 | | - if (qualifiers.isEmpty()) { |
813 | | - // If no other qualifier is used then add @Any |
814 | | - qualifiers.add(AnnotationInstance.create(DotNames.ANY, null, new AnnotationValue[] {})); |
815 | | - } |
816 | | - |
817 | | - Type elementType = injectionPoint.getType().asParameterizedType().arguments().get(0); |
818 | | - |
819 | | - // make note of all types inside @All List<X> to make sure they are unremovable |
820 | | - unremovables.add(new TypeAndQualifiers( |
821 | | - elementType.name().equals(DotNames.INSTANCE_HANDLE) |
822 | | - ? elementType.asParameterizedType().arguments().get(0) |
823 | | - : elementType, |
824 | | - qualifiers)); |
825 | | - } |
826 | | - if (!unremovables.isEmpty()) { |
827 | | - // New beans were registered - we need to re-init the type -> bean map |
828 | | - // Also make all beans that match the List<> injection points unremovable |
829 | | - beanDeployment.initBeanByTypeMap(); |
830 | | - // And make all the matching beans unremovable |
831 | | - unremovableBeans.produce(new UnremovableBeanBuildItem(new Predicate<BeanInfo>() { |
832 | | - @Override |
833 | | - public boolean test(BeanInfo bean) { |
834 | | - for (TypeAndQualifiers tq : unremovables) { |
835 | | - if (Beans.matches(bean, tq)) { |
836 | | - return true; |
837 | | - } |
838 | | - } |
839 | | - return false; |
840 | | - } |
841 | | - })); |
842 | | - } |
843 | | - } |
844 | | - |
845 | | - private boolean isListAllInjectionPoint(InjectionPointInfo injectionPoint) { |
846 | | - return DotNames.LIST.equals(injectionPoint.getRequiredType().name()) |
847 | | - && Annotations.contains(injectionPoint.getRequiredQualifiers(), DotNames.ALL); |
848 | | - } |
849 | | - |
850 | 755 | private abstract static class AbstractCompositeApplicationClassesPredicate<T> implements Predicate<T> { |
851 | 756 |
|
852 | 757 | private final IndexView applicationClassesIndex; |
|
0 commit comments