Repository navigation
Description
What is wrong
maven-shade-plugin rewrites the contents of classes inside META-INF/versions/N/ but does not rewrite their entry paths. The shaded nanometer-api-*-all.jar therefore contains entries like:
META-INF/versions/24/net/bytebuddy/jar/asmjdkbridge/AsmAttribute.class
whose class file actually declares:
class nanometer.shaded.bytebuddy.jar.asmjdkbridge.AsmAttribute
The path says net/bytebuddy, the class says nanometer.shaded.bytebuddy. If such an entry were ever loaded, the JVM would reject it with NoClassDefFoundError: ... wrong name.
Why it does not break today
The shaded JAR's manifest does not carry Multi-Release: true. The ManifestResourceTransformer builds the manifest from the project's own JAR plus the configured manifestEntries, and Byte Buddy's own Multi-Release: true is not carried over. Without that attribute the JVM ignores META-INF/versions/* completely, so the mismatched entries are dead weight that is never loaded.
The JAR works by accident of a missing manifest attribute rather than by design.
Why it is worth fixing
- Anyone who later adds
Multi-Release: true, or swaps in a manifest transformer that preserves it, converts ~41 dead entries into load failures with no obvious connection to the change that caused them. - The artifact ships bytes that can never execute.
- On Java 24+, Byte Buddy silently falls back to its bundled ASM instead of the JDK ClassFile API bridge it ships those entries for. That fallback is functional (the suite passes on JDK 21, 25 and 26) but it is an unintended performance/behaviour choice rather than a decided one.
Scope
This predates the Byte Buddy bump. It already affects the relocated org.sqlite entries under META-INF/versions/9/ on main today, verified by decompiling META-INF/versions/9/org/sqlite/nativeimage/SqliteJdbcFeature.class from a main build and finding it declares nanometer.shaded.sqlite.nativeimage.SqliteJdbcFeature. PR #16 adds 32 more such entries from Byte Buddy 1.18.13.
What it would take
Decide between:
- Strip
META-INF/versions/**from the shaded artifact with a shadefilter, making the fallback explicit and the JAR honest about what it contains. Removes the JDK ClassFile API path permanently. - Keep the versioned entries, relocate their paths correctly, and set
Multi-Release: trueso they are actually used. Needs a check of whether current shade can relocate MR-JAR paths, and a test that loads a versioned class on JDK 24+.
Either way the result needs a check that fails if a shaded entry's path disagrees with its declared class name, so this cannot regress silently.
Why it was not done in #16
#16 is scoped to unblocking the dependency bump in CI. This is a pre-existing artifact-correctness question with a real design decision in it (option 1 versus option 2), and folding it into a build-unblock PR would mix a forced change with a discretionary one.
Activity
fix(build): drop unloadable multi-release entries from the shaded JAR (…
PIsberg commentedon Sep 11, 2026
Fixed in
fix/shade-plugin-mrjar-bytebuddy(PR #16), taking option 1 from the issue.The versioned entries are excluded from the shaded JAR. Since the manifest carries no
Multi-Releaseattribute, the JVM already ignored every one of them, so dropping them removes bytes that could never execute rather than changing behaviour. Option 2 is not reachable with stock shade, which cannot relocateMETA-INF/versions/N/entry paths.The filter covers every artifact rather than only the relocated ones:
org.jspecifyalso contributes aMETA-INF/versions/9module-info.classand OSGi metadata that an uber-JAR cannot use either.ShadedJarLayoutITpins the invariants the issue asked for, and more:META-INF/versionsentries and noMulti-Releasemanifest attribute, so the two cannot drift into the dangerous combinationnet/bytebuddyororg/sqliteclasses, which is the zero-classpath-pollution guaranteePremain-Class,Agent-Classand retransform manifest entries survive shadingVerified by removing the filter and rebuilding:
classPathsMatchDeclaredNamesandcarriesNoMultiReleaseEntriesboth go red and name all 31 offending entries (28 from Byte Buddy 1.18.13, 3 from sqlite).Getting these tests to run at all required adding
maven-failsafe-plugintonanometer-api, so integration tests execute afterpackageand can inspect the artifact that actually ships. The surefire suite only ever sees the unshaded module classpath, which is why both this and #18 were invisible.One consequence worth recording: Byte Buddy on JDK 24+ now permanently falls back to its bundled ASM rather than the JDK ClassFile API bridge those entries provided. That was already true before this change, since the entries were never loaded, but it is now an explicit decision rather than an accident.
feat(build): restore the JDK ClassFile API bridge in the shaded JAR (#20