smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add classname to "Required class information is missing" error

vlsi opened this issue · comments

See https://github.com/wildfly/jandex/blob/7f2c075ba9246e4b6cc8fe7f3e3678dc2b64891c/src/main/java/org/jboss/jandex/Indexer.java#L926

The error message is hard to understand, and the root cause is not clear.

What do you think if the error includes the class name or something else for making the exception actionable?

The current exception:

Caused by: java.lang.IllegalStateException: Required class information is missing
         at org.jboss.jandex.Indexer.rebuildNestedType(Indexer.java:926)
         at org.jboss.jandex.Indexer.resolveTypePath(Indexer.java:786)
         at org.jboss.jandex.Indexer.resolveTypeAnnotation(Indexer.java:705)
         at org.jboss.jandex.Indexer.resolveTypeAnnotations(Indexer.java:613)
         at org.jboss.jandex.Indexer.index(Indexer.java:1602)
         at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.toClassDescriptor(ClassFileArchiveEntryHandler.java:64)
         at org.hibernate.boot.archive.scan.spi.ClassFileArchiveEntryHandler.handleEntry(ClassFileArchiveEntryHandler.java:52)

Context: https://www.postgresql.org/message-id/AM0PR04MB652919E6F344C84DC3073D0D96140%40AM0PR04MB6529.eurprd04.prod.outlook.com

Another exception:

            Caused by: java.lang.IllegalStateException: Class extends type annotation appeared on a non class target
                at org.jboss.jandex.Indexer.processTypeAnnotation(Indexer.java:538)
                at org.jboss.jandex.Indexer.processTypeAnnotations(Indexer.java:515)
                at org.jboss.jandex.Indexer.processAttributes(Indexer.java:355)
                at org.jboss.jandex.Indexer.processMethodInfo(Indexer.java:306)
                at org.jboss.jandex.Indexer.index(Indexer.java:1602)

thanks for the report

Reproducer:

    public static class IteratorSupplier implements Supplier<Consumer<@Nullable Object[]>> {
        @Override
        public Consumer<@Nullable Object[]> get() {
            return new Consumer<@Nullable Object[]>() {
                @Override
                public void accept(@Nullable Object[] objects) {
                }
            };
        }
    }

Then parse IteratorSupplier$1.class (==class file for the anonymous new Consumer)

Signature as compiled with javac 1.8u222:

Signature: #28                          // Ljava/lang/Object;Ljava/util/function/Consumer<[Ljava/lang/Object;>;
SourceFile: "BridgeMethodTest.java"
RuntimeVisibleTypeAnnotations:
  0: #25(): CLASS_EXTENDS, type_index=0, location=[INNER_TYPE, TYPE_ARGUMENT(0), ARRAY]
    org.checkerframework.checker.nullness.qual.Nullable

This might be relevant: https://bugs.openjdk.java.net/browse/JDK-8198945, so it might be yet another javac issue :-/