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 00fe8ebcf5324..f2fb782c542b7 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 @@ -277,7 +277,8 @@ public void transform(TransformationContext transformationContext) { } }); - builder.setBeanArchiveIndex(index); + builder.setComputingBeanArchiveIndex(index); + builder.setImmutableBeanArchiveIndex(beanArchiveIndex.getImmutableIndex()); builder.setApplicationIndex(combinedIndex.getIndex()); List beanDefiningAnnotations = additionalBeanDefiningAnnotations.stream() .map((s) -> new BeanDefiningAnnotation(s.getName(), s.getDefaultScope())).collect(Collectors.toList()); diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveIndexBuildItem.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveIndexBuildItem.java index fbb2813c63846..0c0550f7d7e4a 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveIndexBuildItem.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveIndexBuildItem.java @@ -14,26 +14,42 @@ * Compared to {@link io.quarkus.deployment.builditem.CombinedIndexBuildItem} this index can contain additional classes * that were indexed while bean discovery was in progress. * - * It also holds information about all programmatically registered beans and all generated bean classes. - * * @see GeneratedBeanBuildItem - * @see AdditionalBeanBuildItem * @see io.quarkus.deployment.builditem.CombinedIndexBuildItem */ public final class BeanArchiveIndexBuildItem extends SimpleBuildItem { private final IndexView index; + private final IndexView immutableIndex; private final Set generatedClassNames; - public BeanArchiveIndexBuildItem(IndexView index, Set generatedClassNames) { + public BeanArchiveIndexBuildItem(IndexView index, IndexView immutableIndex, Set generatedClassNames) { this.index = index; + this.immutableIndex = immutableIndex; this.generatedClassNames = generatedClassNames; } + /** + * This index is built on top of the immutable index. + * + * @return the computing index that can also index classes on demand + */ public IndexView getIndex() { return index; } + /** + * + * @return an immutable index that represents the bean archive + */ + public IndexView getImmutableIndex() { + return immutableIndex; + } + + /** + * + * @return the set of classes generated via {@link GeneratedBeanBuildItem} + */ public Set getGeneratedClassNames() { return generatedClassNames; } diff --git a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java index 29283e4df9516..cb75954e4b327 100644 --- a/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java +++ b/extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java @@ -84,12 +84,12 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil additionalClasses.put(knownMissingClass, Optional.empty()); } - // Finally, index ArC/CDI API built-in classes - return new BeanArchiveIndexBuildItem( - BeanArchives.buildBeanArchiveIndex(Thread.currentThread().getContextClassLoader(), additionalClasses, - applicationIndex, - additionalBeanIndexer.complete()), - generatedClassNames); + IndexView immutableBeanArchiveIndex = BeanArchives.buildImmutableBeanArchiveIndex(applicationIndex, + additionalBeanIndexer.complete()); + IndexView computingBeanArchiveIndex = BeanArchives.buildComputingBeanArchiveIndex( + Thread.currentThread().getContextClassLoader(), + additionalClasses, immutableBeanArchiveIndex); + return new BeanArchiveIndexBuildItem(computingBeanArchiveIndex, immutableBeanArchiveIndex, generatedClassNames); } private IndexView buildApplicationIndex(ArcConfig config, ApplicationArchivesBuildItem applicationArchivesBuildItem, diff --git a/extensions/spring-di/deployment/src/test/java/io/quarkus/spring/di/deployment/SpringDIProcessorTest.java b/extensions/spring-di/deployment/src/test/java/io/quarkus/spring/di/deployment/SpringDIProcessorTest.java index 5791891b3fca2..41e6975855dec 100644 --- a/extensions/spring-di/deployment/src/test/java/io/quarkus/spring/di/deployment/SpringDIProcessorTest.java +++ b/extensions/spring-di/deployment/src/test/java/io/quarkus/spring/di/deployment/SpringDIProcessorTest.java @@ -205,7 +205,8 @@ public void getAnnotationsToAddBeanMethodWithScope() { private IndexView getIndex(final Class... classes) { try { Index index = Index.of(classes); - return BeanArchives.buildBeanArchiveIndex(getClass().getClassLoader(), new ConcurrentHashMap<>(), index); + return BeanArchives.buildComputingBeanArchiveIndex(getClass().getClassLoader(), new ConcurrentHashMap<>(), + BeanArchives.buildImmutableBeanArchiveIndex(index)); } catch (IOException e) { throw new IllegalStateException("Failed to index classes", e); } diff --git a/extensions/spring-scheduled/deployment/src/test/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessorTest.java b/extensions/spring-scheduled/deployment/src/test/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessorTest.java index 3abb0f2f3334b..45db58171f526 100644 --- a/extensions/spring-scheduled/deployment/src/test/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessorTest.java +++ b/extensions/spring-scheduled/deployment/src/test/java/io/quarkus/spring/scheduled/deployment/SpringScheduledProcessorTest.java @@ -115,7 +115,8 @@ public void testBuildDelayParamFromInvalidFormat() { private IndexView getIndex(final Class... classes) { try { Index index = Index.of(classes); - return BeanArchives.buildBeanArchiveIndex(getClass().getClassLoader(), new ConcurrentHashMap<>(), index); + return BeanArchives.buildComputingBeanArchiveIndex(getClass().getClassLoader(), new ConcurrentHashMap<>(), + BeanArchives.buildImmutableBeanArchiveIndex(index)); } catch (IOException e) { throw new IllegalStateException("Failed to index classes", e); } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java index 88e8e83a89377..78c2a429fec3c 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/AnnotationLiteralProcessor.java @@ -46,7 +46,7 @@ public class AnnotationLiteralProcessor { generateAnnotationLiteralClassName(key.annotationName()), applicationClassPredicate.test(key.annotationName()), key.annotationClass)); - this.beanArchiveIndex = beanArchiveIndex; + this.beanArchiveIndex = Objects.requireNonNull(beanArchiveIndex); } boolean hasLiteralsToGenerate() { diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java index bd14d9e679fbd..4a6dd5c88542b 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java @@ -52,14 +52,23 @@ public final class BeanArchives { /** * * @param applicationIndexes - * @return the final bean archive index + * @return the immutable bean archive index */ - public static IndexView buildBeanArchiveIndex(ClassLoader deploymentClassLoader, - Map> additionalClasses, IndexView... applicationIndexes) { + public static IndexView buildImmutableBeanArchiveIndex(IndexView... applicationIndexes) { List indexes = new ArrayList<>(); Collections.addAll(indexes, applicationIndexes); indexes.add(buildAdditionalIndex()); - return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, additionalClasses); + return CompositeIndex.create(indexes); + } + + /** + * + * @param wrappedIndexes + * @return the computing bean archive index + */ + public static IndexView buildComputingBeanArchiveIndex(ClassLoader deploymentClassLoader, + Map> additionalClasses, IndexView immutableIndex) { + return new IndexWrapper(immutableIndex, deploymentClassLoader, additionalClasses); } private static IndexView buildAdditionalIndex() { diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java index dfcca8ff7ebde..4997affe0f467 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanDeployment.java @@ -14,6 +14,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.CopyOnWriteArrayList; @@ -55,8 +56,8 @@ public class BeanDeployment { private final BuildContextImpl buildContext; - private final IndexView beanArchiveIndex; - + private final IndexView beanArchiveComputingIndex; + private final IndexView beanArchiveImmutableIndex; private final IndexView applicationIndex; private final Map qualifiers; @@ -124,7 +125,8 @@ public class BeanDeployment { } this.beanDefiningAnnotations = beanDefiningAnnotations; this.resourceAnnotations = new HashSet<>(builder.resourceAnnotations); - this.beanArchiveIndex = builder.beanArchiveIndex; + this.beanArchiveComputingIndex = builder.beanArchiveComputingIndex; + this.beanArchiveImmutableIndex = Objects.requireNonNull(builder.beanArchiveImmutableIndex); this.applicationIndex = builder.applicationIndex; this.annotationStore = new AnnotationStore(initAndSort(builder.annotationTransformers, buildContext), buildContext); if (buildContext != null) { @@ -141,11 +143,11 @@ public class BeanDeployment { this.excludeTypes = builder.excludeTypes != null ? new ArrayList<>(builder.excludeTypes) : Collections.emptyList(); qualifierNonbindingMembers = new HashMap<>(); - qualifiers = findQualifiers(this.beanArchiveIndex); + qualifiers = findQualifiers(); for (QualifierRegistrar registrar : builder.qualifierRegistrars) { for (Map.Entry> entry : registrar.getAdditionalQualifiers().entrySet()) { DotName dotName = entry.getKey(); - ClassInfo classInfo = getClassByName(this.beanArchiveIndex, dotName); + ClassInfo classInfo = getClassByName(getBeanArchiveIndex(), dotName); if (classInfo != null) { Set nonbindingMembers = entry.getValue(); if (nonbindingMembers == null) { @@ -156,15 +158,15 @@ public class BeanDeployment { } } } - repeatingQualifierAnnotations = findContainerAnnotations(qualifiers, this.beanArchiveIndex); + repeatingQualifierAnnotations = findContainerAnnotations(qualifiers); buildContextPut(Key.QUALIFIERS.asString(), Collections.unmodifiableMap(qualifiers)); interceptorNonbindingMembers = new HashMap<>(); - interceptorBindings = findInterceptorBindings(this.beanArchiveIndex); + interceptorBindings = findInterceptorBindings(); for (InterceptorBindingRegistrar registrar : builder.interceptorBindingRegistrars) { for (InterceptorBindingRegistrar.InterceptorBinding binding : registrar.getAdditionalBindings()) { DotName dotName = binding.getName(); - ClassInfo annotationClass = getClassByName(this.beanArchiveIndex, dotName); + ClassInfo annotationClass = getClassByName(getBeanArchiveIndex(), dotName); if (annotationClass != null) { Set nonbinding = new HashSet<>(); for (MethodInfo method : annotationClass.methods()) { @@ -177,7 +179,7 @@ public class BeanDeployment { interceptorBindings.put(dotName, annotationClass); } } - repeatingInterceptorBindingAnnotations = findContainerAnnotations(interceptorBindings, this.beanArchiveIndex); + repeatingInterceptorBindingAnnotations = findContainerAnnotations(interceptorBindings); buildContextPut(Key.INTERCEPTOR_BINDINGS.asString(), Collections.unmodifiableMap(interceptorBindings)); Set additionalStereotypes = new HashSet<>(); @@ -185,12 +187,11 @@ public class BeanDeployment { additionalStereotypes.addAll(stereotypeRegistrar.getAdditionalStereotypes()); } - this.stereotypes = findStereotypes(this.beanArchiveIndex, interceptorBindings, customContexts, additionalStereotypes, + this.stereotypes = findStereotypes(interceptorBindings, customContexts, additionalStereotypes, annotationStore); buildContextPut(Key.STEREOTYPES.asString(), Collections.unmodifiableMap(stereotypes)); this.transitiveInterceptorBindings = findTransitiveInterceptorBindings(interceptorBindings.keySet(), - this.beanArchiveIndex, new HashMap<>(), interceptorBindings, annotationStore); this.injectionPoints = new CopyOnWriteArrayList<>(); @@ -199,7 +200,7 @@ public class BeanDeployment { this.beans = new CopyOnWriteArrayList<>(); this.observers = new CopyOnWriteArrayList<>(); - this.assignabilityCheck = new AssignabilityCheck(beanArchiveIndex, applicationIndex); + this.assignabilityCheck = new AssignabilityCheck(getBeanArchiveIndex(), applicationIndex); this.beanResolver = new BeanResolverImpl(this); this.delegateInjectionPointResolver = new DelegateInjectionPointResolverImpl(this); this.interceptorResolver = new InterceptorResolver(this); @@ -517,12 +518,17 @@ public Collection getStereotypes() { } /** - * This index was used to discover components (beans, interceptors, qualifiers, etc.) and during type-safe resolution. + * Returns the index that was used during discovery and type-safe resolution. + *

+ * In general, the returned index is usually "computing" which means that it attempts to compute the information for the + * classes that were not part of the initial bean archive index. I.e. the returned index corresponds to + * {@link BeanProcessor.Builder#setComputingBeanArchiveIndex(IndexView)}. However, if the computing index was not set then + * the index set by {@link BeanProcessor.Builder#setImmutableBeanArchiveIndex(IndexView)} is used instead. * * @return the bean archive index */ public IndexView getBeanArchiveIndex() { - return beanArchiveIndex; + return beanArchiveComputingIndex != null ? beanArchiveComputingIndex : beanArchiveImmutableIndex; } /** @@ -670,9 +676,9 @@ private void buildContextPut(String key, Object value) { } } - private Map findQualifiers(IndexView index) { + private Map findQualifiers() { Map qualifiers = new HashMap<>(); - for (AnnotationInstance qualifier : index.getAnnotations(DotNames.QUALIFIER)) { + for (AnnotationInstance qualifier : beanArchiveImmutableIndex.getAnnotations(DotNames.QUALIFIER)) { ClassInfo qualifierClass = qualifier.target().asClass(); if (isExcluded(qualifierClass)) { continue; @@ -682,23 +688,23 @@ private Map findQualifiers(IndexView index) { return qualifiers; } - private Map findContainerAnnotations(Map annotations, IndexView index) { + private Map findContainerAnnotations(Map annotations) { Map containerAnnotations = new HashMap<>(); for (ClassInfo annotation : annotations.values()) { AnnotationInstance repeatableMetaAnnotation = annotation.declaredAnnotation(DotNames.REPEATABLE); if (repeatableMetaAnnotation != null) { DotName containerAnnotationName = repeatableMetaAnnotation.value().asClass().name(); - ClassInfo containerClass = getClassByName(index, containerAnnotationName); + ClassInfo containerClass = getClassByName(getBeanArchiveIndex(), containerAnnotationName); containerAnnotations.put(containerAnnotationName, containerClass); } } return containerAnnotations; } - private Map findInterceptorBindings(IndexView index) { + private Map findInterceptorBindings() { Map bindings = new HashMap<>(); // Note: doesn't use AnnotationStore, this will operate on classes without applying annotation transformers - for (AnnotationInstance binding : index.getAnnotations(DotNames.INTERCEPTOR_BINDING)) { + for (AnnotationInstance binding : beanArchiveImmutableIndex.getAnnotations(DotNames.INTERCEPTOR_BINDING)) { ClassInfo bindingClass = binding.target().asClass(); if (isExcluded(bindingClass)) { continue; @@ -709,7 +715,6 @@ private Map findInterceptorBindings(IndexView index) { } private static Map> findTransitiveInterceptorBindings(Collection initialBindings, - IndexView index, Map> result, Map interceptorBindings, AnnotationStore annotationStore) { // for all known interceptor bindings @@ -748,20 +753,20 @@ private static Set recursiveBuild(DotName name, return result; } - private Map findStereotypes(IndexView index, Map interceptorBindings, + private Map findStereotypes(Map interceptorBindings, Map> customContexts, Set additionalStereotypes, AnnotationStore annotationStore) { Map stereotypes = new HashMap<>(); Set stereotypeNames = new HashSet<>(); - for (AnnotationInstance annotation : index.getAnnotations(DotNames.STEREOTYPE)) { + for (AnnotationInstance annotation : beanArchiveImmutableIndex.getAnnotations(DotNames.STEREOTYPE)) { stereotypeNames.add(annotation.target().asClass().name()); } stereotypeNames.addAll(additionalStereotypes); for (DotName stereotypeName : stereotypeNames) { - ClassInfo stereotypeClass = getClassByName(index, stereotypeName); + ClassInfo stereotypeClass = getClassByName(getBeanArchiveIndex(), stereotypeName); if (stereotypeClass != null && !isExcluded(stereotypeClass)) { boolean isAlternative = false; @@ -852,7 +857,8 @@ private List findBeans(Collection beanDefiningAnnotations, Li .map(StereotypeInfo::getName) .collect(Collectors.toSet()); - for (ClassInfo beanClass : beanArchiveIndex.getKnownClasses()) { + // If needed use the specialized immutable index to discover beans + for (ClassInfo beanClass : beanArchiveImmutableIndex.getKnownClasses()) { if (Modifier.isInterface(beanClass.flags()) || Modifier.isAbstract(beanClass.flags()) || beanClass.isAnnotation() || beanClass.isEnum()) { @@ -987,7 +993,7 @@ private List findBeans(Collection beanDefiningAnnotations, Li } DotName superType = aClass.superName(); aClass = superType != null && !superType.equals(DotNames.OBJECT) - ? getClassByName(beanArchiveIndex, superType) + ? getClassByName(getBeanArchiveIndex(), superType) : null; } for (FieldInfo field : beanClass.fields()) { @@ -1233,7 +1239,7 @@ static void processErrors(List errors) { private List findInterceptors(List injectionPoints) { Map interceptorClasses = new HashMap<>(); - for (AnnotationInstance annotation : beanArchiveIndex.getAnnotations(DotNames.INTERCEPTOR)) { + for (AnnotationInstance annotation : beanArchiveImmutableIndex.getAnnotations(DotNames.INTERCEPTOR)) { if (Kind.CLASS.equals(annotation.target().kind())) { interceptorClasses.put(annotation.target().asClass().name(), annotation.target().asClass()); } @@ -1260,7 +1266,7 @@ private List findInterceptors(List injectio private List findDecorators(List injectionPoints) { Map decoratorClasses = new HashMap<>(); - for (AnnotationInstance annotation : beanArchiveIndex.getAnnotations(DotNames.DECORATOR)) { + for (AnnotationInstance annotation : beanArchiveImmutableIndex.getAnnotations(DotNames.DECORATOR)) { if (Kind.CLASS.equals(annotation.target().kind())) { decoratorClasses.put(annotation.target().asClass().name(), annotation.target().asClass()); } diff --git a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java index b869031c5461b..4427cfe4bea47 100644 --- a/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java +++ b/independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanProcessor.java @@ -91,7 +91,10 @@ private BeanProcessor(Builder builder) { this.applicationClassPredicate = builder.applicationClassPredicate; this.name = builder.name; this.output = builder.output; - this.annotationLiterals = new AnnotationLiteralProcessor(builder.beanArchiveIndex, applicationClassPredicate); + this.annotationLiterals = new AnnotationLiteralProcessor( + builder.beanArchiveComputingIndex != null ? builder.beanArchiveComputingIndex + : builder.beanArchiveImmutableIndex, + applicationClassPredicate); this.generateSources = builder.generateSources; this.allowMocking = builder.allowMocking; this.transformUnproxyableClasses = builder.transformUnproxyableClasses; @@ -99,7 +102,9 @@ private BeanProcessor(Builder builder) { // Initialize all build processors buildContext = new BuildContextImpl(); - buildContext.putInternal(Key.INDEX.asString(), builder.beanArchiveIndex); + buildContext.putInternal(Key.INDEX.asString(), + builder.beanArchiveComputingIndex != null ? builder.beanArchiveComputingIndex + : builder.beanArchiveImmutableIndex); this.beanRegistrars = initAndSort(builder.beanRegistrars, buildContext); this.observerRegistrars = initAndSort(builder.observerRegistrars, buildContext); @@ -440,7 +445,8 @@ public Predicate getInjectionPointAnnotationsPredicate() { public static class Builder { String name; - IndexView beanArchiveIndex; + IndexView beanArchiveComputingIndex; + IndexView beanArchiveImmutableIndex; IndexView applicationIndex; Collection additionalBeanDefiningAnnotations; ResourceOutput output; @@ -510,14 +516,33 @@ public Builder setName(String name) { } /** - * Set the bean archive index. This index is mandatory and is used to discover components (beans, interceptors, - * qualifiers, etc.) and during type-safe resolution. + * Set the computing bean archive index. This index is optional and can be used for example during type-safe resolution. + * If it's not set then the immutable index is used instead. + *

+ * The computing index must be built on top of the immutable index and compute only the classes that are not part of the + * immutable index. + *

+ * This index is never used to discover components (beans, observers, etc.). + * + * @param index + * @return self + * @see Builder#setImmutableBeanArchiveIndex(IndexView) + */ + public Builder setComputingBeanArchiveIndex(IndexView index) { + this.beanArchiveComputingIndex = index; + return this; + } + + /** + * Set the immutable bean archive index. This index is mandatory and is used to discover components (beans, observers, + * etc.). * - * @param beanArchiveIndex + * @param index * @return self + * @see Builder#setComputingBeanArchiveIndex(IndexView) */ - public Builder setBeanArchiveIndex(IndexView beanArchiveIndex) { - this.beanArchiveIndex = beanArchiveIndex; + public Builder setImmutableBeanArchiveIndex(IndexView index) { + this.beanArchiveImmutableIndex = index; return this; } @@ -526,11 +551,11 @@ public Builder setBeanArchiveIndex(IndexView beanArchiveIndex) { *

* Some types may not be part of the bean archive index but are still needed during type-safe resolution. * - * @param applicationIndex + * @param index * @return self */ - public Builder setApplicationIndex(IndexView applicationIndex) { - this.applicationIndex = applicationIndex; + public Builder setApplicationIndex(IndexView index) { + this.applicationIndex = index; return this; } diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoInjectionsTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoInjectionsTest.java index 981ae74c5bd4c..ff22bbd568845 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoInjectionsTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoInjectionsTest.java @@ -42,7 +42,7 @@ public void testInjections() throws IOException { Type listStringType = ParameterizedType.create(name(List.class), new Type[] { Type.create(name(String.class), Kind.CLASS) }, null); - BeanDeployment deployment = BeanProcessor.builder().setBeanArchiveIndex(index).build().getBeanDeployment(); + BeanDeployment deployment = BeanProcessor.builder().setImmutableBeanArchiveIndex(index).build().getBeanDeployment(); deployment.registerCustomContexts(Collections.emptyList()); deployment.registerBeans(Collections.emptyList()); BeanInfo barBean = deployment.getBeans().stream().filter(b -> b.getTarget().get().equals(barClass)).findFirst().get(); diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoQualifiersTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoQualifiersTest.java index 6e5203478b4a4..3c95a2c557f76 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoQualifiersTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoQualifiersTest.java @@ -37,7 +37,7 @@ public void testQualifiers() throws IOException { ClassInfo fooClass = index.getClassByName(fooName); BeanInfo bean = Beans.createClassBean(fooClass, - BeanProcessor.builder().setBeanArchiveIndex(index).build().getBeanDeployment(), + BeanProcessor.builder().setImmutableBeanArchiveIndex(index).build().getBeanDeployment(), null); AnnotationInstance requiredFooQualifier = index.getAnnotations(fooQualifierName).stream() diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoTypesTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoTypesTest.java index 75dd27ee2e3e8..bc53674cd78a9 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoTypesTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanInfoTypesTest.java @@ -37,7 +37,7 @@ public void testResolver() throws IOException { Collection.class, List.class, Iterable.class, Object.class, String.class); - BeanDeployment deployment = BeanProcessor.builder().setBeanArchiveIndex(index).build().getBeanDeployment(); + BeanDeployment deployment = BeanProcessor.builder().setImmutableBeanArchiveIndex(index).build().getBeanDeployment(); DotName fooName = name(Foo.class); ClassInfo fooClass = index.getClassByName(fooName); diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java index b6bcc93594732..fbe3e19e240f9 100644 --- a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/TypesTest.java @@ -32,7 +32,8 @@ public void testGetTypeClosure() throws IOException { DotName producerName = DotName.createSimple(Producer.class.getName()); ClassInfo fooClass = index.getClassByName(fooName); Map> resolvedTypeVariables = new HashMap<>(); - BeanDeployment dummyDeployment = BeanProcessor.builder().setBeanArchiveIndex(index).build().getBeanDeployment(); + BeanDeployment dummyDeployment = BeanProcessor.builder().setImmutableBeanArchiveIndex(index).build() + .getBeanDeployment(); // Baz, Foo, Object Set bazTypes = Types.getTypeClosure(index.getClassByName(bazName), null, diff --git a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/ArcTestContainer.java b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/ArcTestContainer.java index 6d428b83335a6..fda3d072e7158 100644 --- a/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/ArcTestContainer.java +++ b/independent-projects/arc/tests/src/test/java/io/quarkus/arc/test/ArcTestContainer.java @@ -20,6 +20,7 @@ import org.jboss.jandex.DotName; import org.jboss.jandex.Index; +import org.jboss.jandex.IndexView; import org.jboss.jandex.Indexer; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeEachCallback; @@ -322,14 +323,14 @@ private ClassLoader init(ExtensionContext context) { Arc.shutdown(); // Build index - Index beanArchiveIndex; + IndexView immutableBeanArchiveIndex; try { - beanArchiveIndex = index(beanClasses); + immutableBeanArchiveIndex = BeanArchives.buildImmutableBeanArchiveIndex(index(beanClasses)); } catch (IOException e) { throw new IllegalStateException("Failed to create index", e); } - Index applicationIndex; + IndexView applicationIndex; if (additionalClasses.isEmpty()) { applicationIndex = null; } else { @@ -370,8 +371,9 @@ private ClassLoader init(ExtensionContext context) { BeanProcessor.Builder builder = BeanProcessor.builder() .setName(testClass.getSimpleName()) - .setBeanArchiveIndex(BeanArchives.buildBeanArchiveIndex(getClass().getClassLoader(), - new ConcurrentHashMap<>(), beanArchiveIndex)) + .setImmutableBeanArchiveIndex(immutableBeanArchiveIndex) + .setComputingBeanArchiveIndex(BeanArchives.buildComputingBeanArchiveIndex(getClass().getClassLoader(), + new ConcurrentHashMap<>(), immutableBeanArchiveIndex)) .setApplicationIndex(applicationIndex); if (!resourceAnnotations.isEmpty()) { builder.addResourceAnnotations(resourceAnnotations.stream()