smallrye / jandex

Java Annotation Indexer

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Exception when indexing guava-30.0-jre

bennypi opened this issue · comments

jandex is not capable of parsing the current guava release, guava-30.0-jre. It fails when indexing ClosingFuture.class.
Please see the stacktrace:

java -jar ~/.m2/repository/org/jboss/jandex/2.2.1.Final/jandex-2.2.1.Final.jar ~/.m2/repository/com/google/guava/guava/30.0-jre/guava-30.0-jre.jar
ERROR: Could not index com/google/common/util/concurrent/ClosingFuture.class: Class extends type annotation appeared on a non class target
java.lang.IllegalStateException
	at org.jboss.jandex.IndexWriterV2$ReferenceTable.getReferenceEntry(IndexWriterV2.java:125)
	at org.jboss.jandex.IndexWriterV2$ReferenceTable.positionOf(IndexWriterV2.java:132)
	at org.jboss.jandex.IndexWriterV2.positionOf(IndexWriterV2.java:448)
	at org.jboss.jandex.IndexWriterV2.writeTypeTargetFields(IndexWriterV2.java:381)
	at org.jboss.jandex.IndexWriterV2.writeTypeTarget(IndexWriterV2.java:366)
	at org.jboss.jandex.IndexWriterV2.writeAnnotationTarget(IndexWriterV2.java:335)
	at org.jboss.jandex.IndexWriterV2.writeAnnotation(IndexWriterV2.java:319)
	at org.jboss.jandex.IndexWriterV2.writeReferenceOrFull(IndexWriterV2.java:614)
	at org.jboss.jandex.IndexWriterV2.writeClassEntry(IndexWriterV2.java:537)
	at org.jboss.jandex.IndexWriterV2.writeClasses(IndexWriterV2.java:472)
	at org.jboss.jandex.IndexWriterV2.write(IndexWriterV2.java:207)
	at org.jboss.jandex.IndexWriter.write(IndexWriter.java:107)
	at org.jboss.jandex.IndexWriter.write(IndexWriter.java:74)
	at org.jboss.jandex.JarIndexer.createJarIndex(JarIndexer.java:193)
	at org.jboss.jandex.JarIndexer.createJarIndex(JarIndexer.java:86)
	at org.jboss.jandex.Main.getIndex(Main.java:87)
	at org.jboss.jandex.Main.execute(Main.java:68)
	at org.jboss.jandex.Main.main(Main.java:53)

I became aware of this problem because a deployment of mine is using this version of guava, and when I deploy the EAR in to JBoss EAP 7.3.2, a warning with a similar stacktrace is thrown. The version of jandex in the JBoss is jandex-2.1.2.Final-redhat-00001, however this problem still exists with the 2.2.1 release.

@bennypi thanks for the report. This is an unusual one, but I will get this fixed quickly.

@bennypi this is fixed in 2.2.2.Final and 2.1.4.Final. It may take 24 hours for the release to sync to maven central

I can confirm i was getting this error in Eclipse with Gauva 30. I replaced jandex 2.1.2 in Eclipse with 2.1.4 and the error is resolved. Thank you!

Had the same problem with guava 30.0-jre as a transitive dependency of jwks-rsa. What worked for me was overriding the transitive dependency with version 30.1-jre:

<!-- https://mvnrepository.com/artifact/com.auth0/jwks-rsa -->
<dependency>
  <groupId>com.auth0</groupId>
  <artifactId>jwks-rsa</artifactId>
  <version>0.15.0</version>
  <exclusions>
    <exclusion>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
    </exclusion>
  </exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
  <groupId>com.google.guava</groupId>
  <artifactId>guava</artifactId>
  <version>30.1-jre</version>
</dependency>

So the issue is fixed in 30.1 ?

Seems like it. Though, they don't address it in the changelog and I can't tell what change to ClosingFuture.java fixed it from the diff.

Well that is good news. It was driving me nuts.