smallrye / jandex

Java Annotation Indexer
Apache License 2.0
395 stars 94 forks source link

NullPointerException scanning org.snmp4j-snmp4j-3.6.4.jar #164

Closed jellisgwn closed 2 years ago

jellisgwn commented 2 years ago

Following NPE is seen with Java11 during wildfly-26.0.0.Final startup with jandex-2.4.1.Final:

2022-01-13 15:37:27,332 WARN  [as.server.deployment] WFLYSRV0003: Could not index class module-info.class at /opt/wildfly/standalone/deployments/app.ear/lib/org.snmp4j-snmp4j-3.6.4.jar: java.lang.NullPointerException
    at org.jboss.jandex@2.4.1.Final//org.jboss.jandex.Indexer.processModulePackages(Indexer.java:559)
    at org.jboss.jandex@2.4.1.Final//org.jboss.jandex.Indexer.processAttributes(Indexer.java:432)
    at org.jboss.jandex@2.4.1.Final//org.jboss.jandex.Indexer.index(Indexer.java:1976)
    at org.jboss.as.server@18.0.0.Final//org.jboss.as.server.deployment.annotation.ResourceRootIndexer.indexResourceRoot(ResourceRootIndexer.java:99)
    at org.jboss.as.server@18.0.0.Final//org.jboss.as.server.deployment.annotation.AnnotationIndexProcessor.deploy(AnnotationIndexProcessor.java:51)
    at org.jboss.as.server@18.0.0.Final//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(Thread.java:834)

Haven't had time to investigate yet, but will update when i get to it.

Ladicek commented 2 years ago

This is because in the module-info.class file, the ModulePackages and ModuleMainClass attributes precede the Module attribute, so when parsing the 2 attributes, the module structure isn't created yet. I'm not sure if the JVMS prescribes order here, but even if it did, there's an artifact out there which doesn't follow it.

I'll figure out how to make module parsing order-independent, that shouldn't be too hard.

jellisgwn commented 2 years ago

Went to take a look at the source, and don't see anything strange:

module org.snmp4j {
    requires transitive java.logging;
    exports org.snmp4j;
    exports org.snmp4j.asn1;
    exports org.snmp4j.event;
    exports org.snmp4j.log;
    exports org.snmp4j.mp;
    exports org.snmp4j.security;
    exports org.snmp4j.security.dh;
    exports org.snmp4j.security.nonstandard;
    exports org.snmp4j.smi;
    exports org.snmp4j.transport.tls;
    exports org.snmp4j.transport;
    exports org.snmp4j.uri;
    exports org.snmp4j.util;
    exports org.snmp4j.version;
    exports org.snmp4j.fluent;
    exports org.snmp4j.cfg;
}

my other option was to go back to the snmp4j project and suggest a change...

Ladicek commented 2 years ago

There's nothing wrong in the snmp4j project. Jandex just assumed certain order of things in the compiled bytecode, and that assumption is invalid. It's an easy fix.

Ladicek commented 2 years ago

BTW is there a bug report in the WildFly issue tracker?

jellisgwn commented 2 years ago

No WildFly issue currently. It would be great if this could make it into Wildfly-26.0.1.Final... if that ship hasn't already sailed!

Ladicek commented 2 years ago

I have no influence over that. Feel free to file an issue in the WildFly issue tracker and ask for prioritization there. I can get the WildFly team a Jandex release pretty quickly.