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

NegativeArraySizeException while scanning groovy-3.0.13.jar #279

Closed
papegaaij opened this issue Nov 8, 2022 · 1 comment · Fixed by #280
Closed

NegativeArraySizeException while scanning groovy-3.0.13.jar #279

papegaaij opened this issue Nov 8, 2022 · 1 comment · Fixed by #280
Assignees
Milestone

Comments

@papegaaij
Copy link

Since WildFly 27.0.0.Beta1, we are getting the following java.lang.NegativeArraySizeException when deploying our application in test mode (I've patched jandex to version 3.0.2):

2022-11-08 19:21:58,416 WARN  [org.jboss.as.server.deployment] (MSC service thread 1-8) WFLYSRV0003: Could not index class org/codehaus/groovy/transform/tailrec/VariableReplacedListener$1.class at /content/keyhub-ear.ear/lib/arquillian-spock.jar: java.lang.NegativeArraySizeException: -1
        at io.smallrye.jandex//org.jboss.jandex.Indexer.adjustMethodParameters(Indexer.java:914)
        at io.smallrye.jandex//org.jboss.jandex.Indexer.indexWithSummary(Indexer.java:2322)
        at io.smallrye.jandex//org.jboss.jandex.Indexer.index(Indexer.java:2277)
        at org.jboss.as.server@19.0.0.Beta18//org.jboss.as.server.deployment.annotation.ResourceRootIndexer.indexResourceRoot(ResourceRootIndexer.java:99)
        at org.jboss.as.server@19.0.0.Beta18//org.jboss.as.server.deployment.annotation.AnnotationIndexProcessor.deploy(AnnotationIndexProcessor.java:51)
        at org.jboss.as.server@19.0.0.Beta18//org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:182)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1739)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$StartTask.execute(ServiceControllerImpl.java:1701)
        at org.jboss.msc@1.4.13.Final//org.jboss.msc.service.ServiceControllerImpl$ControllerTask.run(ServiceControllerImpl.java:1559)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
        at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1377)
        at java.base/java.lang.Thread.run(Unknown Source)

The class it is failing on is from groovy-3.0.13.jar and I've confirmed that this bug is still present in main and can be reproduced with:

papegaaij@papegaaij:~/tmp/jandex (main u=)$ java -jar core/target/jandex-3.0.3-SNAPSHOT.jar ~/.m2/repository/org/codehaus/groovy/groovy/3.0.13/groovy-3.0.13.jar
ERROR: Could not index org/codehaus/groovy/transform/tailrec/VariableReplacedListener$1.class: -1
java.lang.NullPointerException: Cannot read the array length because "<local4>" is null
        at org.jboss.jandex.Indexer.propagateTypeVariables(Indexer.java:2740)
        at org.jboss.jandex.Indexer.complete(Indexer.java:2378)
        at org.jboss.jandex.JarIndexer.createJarIndex(JarIndexer.java:196)
        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)

Bisection pointed to this commmit: 58de831. I hope this helps in tracking this down.

@Ladicek Ladicek self-assigned this Nov 9, 2022
@Ladicek
Copy link
Contributor

Ladicek commented Nov 9, 2022

The Groovy compiler emits interesting bytecode. The VariableReplacedListener$1 class looks like an inner class (that is, non-static member class), but its constructor doesn't accept an instance of the enclosing class. I guess that's perfectly legal from JVMS perspective -- Jandex probably has too much assumptions about how inner classes look, based on the JLS. Fortunately, it should be straightforward to relax that assumption.

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