Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalStateException: Missing in reference table while indexing guava #256

Closed
MikeEdgar opened this issue Sep 8, 2022 · 6 comments · Fixed by #257
Closed

IllegalStateException: Missing in reference table while indexing guava #256

MikeEdgar opened this issue Sep 8, 2022 · 6 comments · Fixed by #257
Assignees
Milestone

Comments

@MikeEdgar
Copy link
Member

The error varies by version, but the stack trace is the same -

$ java -jar ~/.m2/repository/io/smallrye/jandex/3.0.0/jandex-3.0.0.jar ~/.m2/repository/com/google/guava/guava/29.0-jre/guava-29.0-jre.jar
java.lang.IllegalStateException: Missing in reference table: @Nullable K
	at org.jboss.jandex.IndexWriterV2$ReferenceTable.getReferenceEntry(IndexWriterV2.java:128)
	at org.jboss.jandex.IndexWriterV2$ReferenceTable.positionOf(IndexWriterV2.java:134)
	at org.jboss.jandex.IndexWriterV2.positionOf(IndexWriterV2.java:520)
	at org.jboss.jandex.IndexWriterV2.writeTypeTargetFields(IndexWriterV2.java:429)
	at org.jboss.jandex.IndexWriterV2.writeTypeTarget(IndexWriterV2.java:403)
	at org.jboss.jandex.IndexWriterV2.writeAnnotationTarget(IndexWriterV2.java:380)
	at org.jboss.jandex.IndexWriterV2.writeAnnotation(IndexWriterV2.java:361)
	at org.jboss.jandex.IndexWriterV2.writeReferenceOrFull(IndexWriterV2.java:818)
	at org.jboss.jandex.IndexWriterV2.writeAnnotations(IndexWriterV2.java:782)
	at org.jboss.jandex.IndexWriterV2.writeMethodEntry(IndexWriterV2.java:355)
	at org.jboss.jandex.IndexWriterV2.writeMethodTable(IndexWriterV2.java:292)
	at org.jboss.jandex.IndexWriterV2.write(IndexWriterV2.java:214)
	at org.jboss.jandex.IndexWriter.write(IndexWriter.java:102)
	at org.jboss.jandex.IndexWriter.write(IndexWriter.java:66)
	at org.jboss.jandex.JarIndexer.createJarIndex(JarIndexer.java:197)
	at org.jboss.jandex.JarIndexer.createJarIndex(JarIndexer.java:88)
	at org.jboss.jandex.Main.getIndex(Main.java:88)
	at org.jboss.jandex.Main.execute(Main.java:68)
	at org.jboss.jandex.Main.main(Main.java:53)

The android variant of guava does not seem to be affected:

$ java -jar ~/.m2/repository/io/smallrye/jandex/3.0.0/jandex-3.0.0.jar ~/.m2/repository/com/google/guava/guava/29.0-android/guava-29.0-android.jar
Wrote /home/michael/.m2/repository/com/google/guava/guava/29.0-android/guava-29.0-android-jar.idx in 0.5280 seconds (1899 classes, 28 annotations, 4571 instances, 17761 class usages, 502380 bytes)
@Ladicek
Copy link
Collaborator

Ladicek commented Sep 8, 2022

Ah, I thought I did pretty comprehensive testing, but apparently I missed some cases. Let me take a look, thanks for the report!

@Ladicek
Copy link
Collaborator

Ladicek commented Sep 8, 2022

Okay, the reproducer took me a while to minimize, it apparently requires a deeper inheritance hierarchy. This class and all its nested classes, when indexed, reproduce the problem:

class Reproducer<T> {
    class Foo {
        void foo(@MyAnnotation("same") T value) {
        }
    }

    class Bar extends Foo {
        void bar(@MyAnnotation("same") T value) {
        }
    }

    class Baz extends Bar {
        void baz(@MyAnnotation("same") T value) {
        }
    }
}

(Where @MyAnnotation has a @Target that includes TYPE_USE.)

@Ladicek Ladicek added this to the 3.0.1 milestone Sep 9, 2022
@Ladicek Ladicek self-assigned this Sep 9, 2022
@Ladicek
Copy link
Collaborator

Ladicek commented Sep 9, 2022

This should be fixed in main now. Feel free to do some testing with a snapshot, because I need to fix one more issue before releasing 3.0.1.

@MikeEdgar
Copy link
Member Author

MikeEdgar commented Sep 9, 2022

I'll take a look, thank you for the quick fix 👍

edit: Looks good with a smoke test of the guava Jar. The andoid jar index even shrank.

3.0.0:

guava-29.0-android-jar.idx in 0.5280 seconds (1899 classes, 28 annotations, 4571 instances, 17761 class usages, 502380 bytes)

3.0.1-SNAPSHOT:

guava-29.0-android-jar.idx in 0.5560 seconds (1899 classes, 28 annotations, 4571 instances, 17761 class usages, 499812 bytes)

@Ladicek
Copy link
Collaborator

Ladicek commented Sep 12, 2022

That's funny. I spent a few minutes searching for the difference and found this document: https://docs.google.com/document/d/1NYGbfz56C0Oh4IGymXjeQUVK4FcRiqDbpc4vGLnDMrY/edit Apparently the -android flavor of Guava omits some methods, which would explain the index size difference.

@Ladicek
Copy link
Collaborator

Ladicek commented Sep 16, 2022

FYI I've released 3.0.1 earlier today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants