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 90695d500d94f..e54908eb06fee 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 @@ -279,6 +279,10 @@ static boolean index(Indexer indexer, String className, ClassLoader classLoader) // Ignore primitives and arrays return false; } + if (isInUnnamedPackage(className)) { + LOGGER.debugf("Class %s is defined in an unnamed package; skipping indexing", className); + return false; + } try (InputStream stream = classLoader .getResourceAsStream(className.replace('.', '/') + ".class")) { if (stream != null) { @@ -292,4 +296,8 @@ static boolean index(Indexer indexer, String className, ClassLoader classLoader) } return result; } + + private static boolean isInUnnamedPackage(String className) { + return !className.contains("."); + } } diff --git a/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanArchivesTest.java b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanArchivesTest.java new file mode 100644 index 0000000000000..bc33c4c92b5a9 --- /dev/null +++ b/independent-projects/arc/processor/src/test/java/io/quarkus/arc/processor/BeanArchivesTest.java @@ -0,0 +1,16 @@ +package io.quarkus.arc.processor; + +import org.jboss.jandex.Indexer; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class BeanArchivesTest { + + @Test + public void testIndex() { + final Indexer indexer = new Indexer(); + Assertions.assertFalse(BeanArchives.index(indexer, "String")); + Assertions.assertTrue(BeanArchives.index(indexer, String.class.getName())); + } + +}