Repository: quarkusio/quarkus
Issue: spring-di - WARN Failed to index org.osgi.annotation.bundle.Requirements

### Describe the bug

spring-di - WARN Failed to index org.osgi.annotation.bundle.Requirements

This wasn't happening in previous Quarkus releases

```
mvn quarkus:dev
...
2022-11-11 15:04:25,550 WARN  [io.qua.arc.pro.BeanArchives] (build-9) Failed to index org.osgi.annotation.bundle.Requirements: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@2b4bac49
...
```

### Expected behavior

No warning

### Actual behavior

`2022-11-11 14:57:43,349 WARN  [io.qua.arc.pro.BeanArchives] (build-13) Failed to index org.osgi.annotation.bundle.Requirements: Class does not exist in ClassLoader QuarkusClassLoader:Deployment Class Loader: DEV@50a7bc6e`

### How to Reproduce?

 - generate app which is using `spring-di`
 - run `mvn quarkus:dev`
 - check the log

### Output of `uname -a` or `ver`

macOS

### Output of `java -version`

Java 11

### GraalVM version (if different from Java)

_No response_

### Quarkus version or git rev

2.14.0.Final

### Build tool (ie. output of `mvnw --version` or `gradlew --version`)

_No response_

### Additional information

_No response_

Changed files:
independent-projects/arc/processor/src/main/java/io/quarkus/arc/processor/BeanArchives.java
extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/BeanArchiveProcessor.java
core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java
core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java

diff --git a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java
index d0d4cbee7f0..c3be954fafd 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/index/IndexingUtil.java
@@ -12,6 +12,7 @@
 import java.nio.file.Path;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashSet;
 import java.util.Set;
 import java.util.function.Function;
 import java.util.jar.JarEntry;
@@ -131,6 +132,11 @@ private static Index indexJar(JarFile file, Set<String> removed) throws IOExcept
 
     public static void indexClass(String className, Indexer indexer, IndexView quarkusIndex,
             Set<DotName> additionalIndex, ClassLoader classLoader) {
+        indexClass(className, indexer, quarkusIndex, additionalIndex, new HashSet<>(), classLoader);
+    }
+
+    public static void indexClass(String className, Indexer indexer, IndexView quarkusIndex,
+            Set<DotName> additionalIndex, Set<DotName> knownMissingClasses, ClassLoader classLoader) {
         DotName classDotName = DotName.createSimple(className);
         if (additionalIndex.contains(classDotName)) {
             return;
@@ -162,10 +168,11 @@ public static void indexClass(String className, Indexer indexer, IndexView quark
                 try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) {
                     if (annotationStream == null) {
                         log.debugf("Could not index annotation: %s (missing class or dependency)", annotationName);
+                        knownMissingClasses.add(annotationName);
                     } else {
                         log.debugf("Index annotation: %s", annotationName);
-                        indexer.index(annotationStream);
-                        additionalIndex.add(annotationName);
+                        indexClass(annotationName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses,
+                                classLoader);
                     }
                 } catch (IOException e) {
                     throw new IllegalStateException("Failed to index: " + className, e);
@@ -173,12 +180,17 @@ public static void indexClass(String className, Indexer indexer, IndexView quark
             }
         }
         if (superclassName != null && !superclassName.equals(OBJECT)) {
-            indexClass(superclassName.toString(), indexer, quarkusIndex, additionalIndex, classLoader);
+            indexClass(superclassName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses, classLoader);
         }
     }
 
     public static void indexClass(String className, Indexer indexer,
-            IndexView quarkusIndex, Set<DotName> additionalIndex,
+            IndexView quarkusIndex, Set<DotName> additionalIndex, ClassLoader classLoader, byte[] beanData) {
+        indexClass(className, indexer, quarkusIndex, additionalIndex, new HashSet<>(), classLoader, beanData);
+    }
+
+    public static void indexClass(String className, Indexer indexer,
+            IndexView quarkusIndex, Set<DotName> additionalIndex, Set<DotName> knownMissingClasses,
             ClassLoader classLoader, byte[] beanData) {
         DotName classDotName = DotName.createSimple(className);
         if (additionalIndex.contains(classDotName)) {
@@ -206,9 +218,15 @@ public static void indexClass(String className, Indexer indexer,
         for (DotName annotationName : annotationNames) {
             if (!additionalIndex.contains(annotationName) && quarkusIndex.getClassByName(annotationName) == null) {
                 try (InputStream annotationStream = IoUtil.readClass(classLoader, annotationName.toString())) {
-                    log.debugf("Index annotation: %s", annotationName);
-                    indexer.index(annotationStream);
-                    additionalIndex.add(annotationName);
+                    if (annotationStream == null) {
+                        log.debugf("Could not index annotation: %s (missing class or dependency)", annotationName);
+                        knownMissingClasses.add(annotationName);
+                    } else {
+                        log.debugf("Index annotation: %s", annotationName);
+                        indexClass(annotationName.toString(), indexer, quarkusIndex, additionalIndex, knownMissingClasses,
+                                classLoader);
+                        additionalIndex.add(annotationName);
+                    }
                 } catch (IOException e) {
                     throw new IllegalStateException("Failed to index: " + className, e);
                 }
diff --git a/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java
index 922b36d759f..cc4cc69774c 100644
--- a/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java
+++ b/core/deployment/src/main/java/io/quarkus/deployment/steps/CombinedIndexBuildStep.java
@@ -3,8 +3,11 @@
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
+import java.util.Optional;
 import java.util.Set;
 
+import org.jboss.jandex.ClassInfo;
 import org.jboss.jandex.CompositeIndex;
 import org.jboss.jandex.DotName;
 import org.jboss.jandex.IndexView;
@@ -37,11 +40,12 @@ CombinedIndexBuildItem build(ApplicationArchivesBuildItem archives,
 
         Indexer indexer = new Indexer();
         Set<DotName> additionalIndex = new HashSet<>();
+        Set<DotName> knownMissingClasses = new HashSet<>();
 
         for (AdditionalIndexedClassesBuildItem additionalIndexedClasses : additionalIndexedClassesItems) {
             for (String classToIndex : additionalIndexedClasses.getClassesToIndex()) {
                 IndexingUtil.indexClass(classToIndex, indexer, archivesIndex, additionalIndex,
-                        Thread.currentThread().getContextClassLoader());
+                        knownMissingClasses, Thread.currentThread().getContextClassLoader());
             }
         }
 
@@ -51,6 +55,11 @@ CombinedIndexBuildItem build(ApplicationArchivesBuildItem archives,
             liveReloadBuildItem.setContextObject(PersistentClassIndex.class, index);
         }
 
+        Map<DotName, Optional<ClassInfo>> additionalClasses = index.getAdditionalClasses();
+        for (DotName knownMissingClass : knownMissingClasses) {
+            additionalClasses.put(knownMissingClass, Optional.empty());
+        }
+
         CompositeIndex compositeIndex = CompositeIndex.create(archivesIndex, indexer.complete());
         RuntimeUpdatesProcessor.setLastStartIndex(compositeIndex);
         return new CombinedIndexBuildItem(compositeIndex,
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 3a050a14239..29283e4df95 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
@@ -4,6 +4,7 @@
 import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
@@ -11,6 +12,7 @@
 
 import org.jboss.jandex.AnnotationInstance;
 import org.jboss.jandex.AnnotationTarget.Kind;
+import org.jboss.jandex.ClassInfo;
 import org.jboss.jandex.CompositeIndex;
 import org.jboss.jandex.DotName;
 import org.jboss.jandex.IndexView;
@@ -57,15 +59,15 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil
 
         // Build the index for additional beans and generated bean classes
         Set<DotName> additionalIndex = new HashSet<>();
+        Set<DotName> knownMissingClasses = new HashSet<>();
         for (String beanClass : additionalBeanClasses) {
             IndexingUtil.indexClass(beanClass, additionalBeanIndexer, applicationIndex, additionalIndex,
-                    Thread.currentThread().getContextClassLoader());
+                    knownMissingClasses, Thread.currentThread().getContextClassLoader());
         }
         Set<DotName> generatedClassNames = new HashSet<>();
         for (GeneratedBeanBuildItem generatedBeanClass : generatedBeans) {
             IndexingUtil.indexClass(generatedBeanClass.getName(), additionalBeanIndexer, applicationIndex, additionalIndex,
-                    Thread.currentThread().getContextClassLoader(),
-                    generatedBeanClass.getData());
+                    knownMissingClasses, Thread.currentThread().getContextClassLoader(), generatedBeanClass.getData());
             generatedClassNames.add(DotName.createSimple(generatedBeanClass.getName().replace('/', '.')));
             generatedClass.produce(new GeneratedClassBuildItem(true, generatedBeanClass.getName(), generatedBeanClass.getData(),
                     generatedBeanClass.getSource()));
@@ -77,9 +79,14 @@ public BeanArchiveIndexBuildItem build(ArcConfig config, ApplicationArchivesBuil
             liveReloadBuildItem.setContextObject(PersistentClassIndex.class, index);
         }
 
+        Map<DotName, Optional<ClassInfo>> additionalClasses = index.getAdditionalClasses();
+        for (DotName knownMissingClass : knownMissingClasses) {
+            additionalClasses.put(knownMissingClass, Optional.empty());
+        }
+
         // Finally, index ArC/CDI API built-in classes
         return new BeanArchiveIndexBuildItem(
-                BeanArchives.buildBeanArchiveIndex(Thread.currentThread().getContextClassLoader(), index.getAdditionalClasses(),
+                BeanArchives.buildBeanArchiveIndex(Thread.currentThread().getContextClassLoader(), additionalClasses,
                         applicationIndex,
                         additionalBeanIndexer.complete()),
                 generatedClassNames);
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 b2a7320b751..bd14d9e679f 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
@@ -55,12 +55,11 @@ public final class BeanArchives {
      * @return the final bean archive index
      */
     public static IndexView buildBeanArchiveIndex(ClassLoader deploymentClassLoader,
-            Map<DotName, Optional<ClassInfo>> persistentClassIndex,
-            IndexView... applicationIndexes) {
+            Map<DotName, Optional<ClassInfo>> additionalClasses, IndexView... applicationIndexes) {
         List<IndexView> indexes = new ArrayList<>();
         Collections.addAll(indexes, applicationIndexes);
         indexes.add(buildAdditionalIndex());
-        return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, persistentClassIndex);
+        return new IndexWrapper(CompositeIndex.create(indexes), deploymentClassLoader, additionalClasses);
     }
 
     private static IndexView buildAdditionalIndex() {