Skip to content

Exception in Index.singleClass() when applied to module-info.class #436

@bbobcik

Description

@bbobcik

When a client invokes method singleClass() on org.jboss.jandex.Index and provides an argument that represents module-info.class, the method fails with NoSuchElements exception. This is caused by an assumption that a map holding known classes is never empty and therefore it is safe to call .iterator().next():

public static ClassInfo singleClass(Class<?> clazz) throws IOException {
Indexer indexer = new Indexer();
indexer.indexClass(clazz);
Index index = indexer.complete();
return index.getKnownClasses().iterator().next();
}

In my case it occurs in WildFly 33.0.1, while trying to examine bean archive candidate Wicket-CDI 10.1.0; the deployment attempt is immediately aborted. When I manually deleted module-info.class from the Wicket-CDI JAR file, the deployment worked as expected. (The mentioned version of WildFly contains Jandex version 3.2.0 within its system modules.)

I believe the correct response would be to return null.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions