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

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

Closed
bbobcik opened this issue Sep 9, 2024 · 2 comments · Fixed by #437
Closed

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

bbobcik opened this issue Sep 9, 2024 · 2 comments · Fixed by #437
Assignees
Milestone

Comments

@bbobcik
Copy link

bbobcik commented Sep 9, 2024

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.

@Ladicek
Copy link
Contributor

Ladicek commented Sep 9, 2024

That doesn't seem right on the first sight, even a module-info.class should result in a valid ClassInfo. I'll take a look.

@Ladicek
Copy link
Contributor

Ladicek commented Sep 9, 2024

Ah, now I understand. Indexer.processClassInfo() does

if (!currentClass.isModule()) {
    classes.put(currentClass.name(), currentClass);
}

so while there is a ClassInfo for the module, it isn't put into the map of classes. Should be straightforward -- if Index.singleClass() gets an Index with no classes, check the modules.

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