atteo / classindex

Index classes, do not scan them!
Apache License 2.0
263 stars 43 forks source link

ClassIndex must check for NoClassDefFoundError also #56

Closed ptahchiev closed 4 years ago

ptahchiev commented 4 years ago

At the moment the ClassIndex is only checking for a ClassNotFoundException during class loading: https://github.com/atteo/classindex/blob/master/classindex/src/main/java/org/atteo/classindex/ClassIndex.java#L404-L406

However, I believe it should be checking also for NoClassDefFoundError (see image): noclassdeffound

I have a maven project with two modules:

Then the client has the option to chose which combination of modules to add in their classpath - moduleA, moduleB, both modules or none of the modules.

If the customer selects moduleB only then I try to find subclasses:

ClassFilter.only().topLevel().from(ClassIndex.getSubclasses(AbstractEntityDefinition.class))

and then it fails with NoClassDefFoundError because the index file in moduleB was created when moduleA was there during compile time but is missing at runtime now.

ptahchiev commented 4 years ago

Any idea when the next release will be out?

sentinelt commented 4 years ago

I've released version 3.9 just a minute ago. Should appear in Maven Central in about a day.