paul-bennett / juggle

A declarative search tool for Java APIs
Apache License 2.0
5 stars 0 forks source link

Add support for multi-release JAR files #124

Open paul-bennett opened 4 days ago

paul-bennett commented 4 days ago

When reading muti-release JAR files, Juggle tries to load classes from all META-INF/versions directories without stripping the directory prefix. Such loads fail, resulting in warning messages like the following.

*** Warning: related class META-INF.versions.9.org.sqlite.nativeimage.SqliteJdbcFeature$SqliteJdbcFeatureException: java.lang.NoClassDefFoundError: META-INF/versions/9/org/sqlite/nativeimage/SqliteJdbcFeature$SqliteJdbcFeatureException (wrong name: org/sqlite/nativeimage/SqliteJdbcFeature$SqliteJdbcFeatureException)
*** Warning: related class META-INF.versions.9.org.sqlite.nativeimage.SqliteJdbcFeature$1: java.lang.NoClassDefFoundError: META-INF/versions/9/org/sqlite/nativeimage/SqliteJdbcFeature$1 (wrong name: org/sqlite/nativeimage/SqliteJdbcFeature$1)
*** Warning: related class META-INF.versions.9.org.sqlite.nativeimage.SqliteJdbcFeature: java.lang.NoClassDefFoundError: META-INF/versions/9/org/sqlite/nativeimage/SqliteJdbcFeature (wrong name: org/sqlite/nativeimage/SqliteJdbcFeature)

Juggle should know about multi-release files and behave accordingly

paul-bennett commented 4 days ago

Issue could be resolve by using JarFile.versionedStream() rather than JarFile.stream() here: https://github.com/paul-bennett/juggle/blob/c7f301760c919528a6fbe38bb8c20452f8257590/src/main/java/com/angellane/juggle/source/FileSource.java#L67

This will cause Juggle to only load the most recent class from the multi-release file.

The fix needs a good test case before committing.