Skip to content

[MSHADE-460] - Preserve multi-release JAR semantics - #831

Open
wilx wants to merge 2 commits into
apache:masterfrom
wilx:issue-672-multi-release-manifest
Open

[MSHADE-460] - Preserve multi-release JAR semantics#831
wilx wants to merge 2 commits into
apache:masterfrom
wilx:issue-672-multi-release-manifest

Conversation

@wilx

@wilx wilx commented Jul 31, 2026

Copy link
Copy Markdown

Fixes #672.
Fixes #652.
Fixes #463.
Fixes #696.

Summary

Preserve multi-release JAR semantics when dependencies are incorporated into a
shaded artifact.

The shaded manifest now receives Multi-Release: true when any included input
is a multi-release JAR. An explicit Multi-Release: false remains authoritative
and produces a warning explaining that versioned entries will not be active.

Relocation now operates on the logical path below
META-INF/versions/<release>/, so versioned classes and resources remain
aligned with their root entries. Minimization likewise treats all physical
versions of a class as the same logical class. Root and versioned
module-info.class entries continue to be discarded; this change does not
introduce module descriptor merging.

Root cause

Shade copied versioned entries but retained only the first input manifest.
This could leave the versioned entries inactive. Relocation also evaluated the
physical META-INF/versions/<release>/... path, which prevented ordinary
package relocation rules from matching versioned classes and resources.
Finally, minimization treated a versioned class path as a distinct class name.

Tests

The new integration coverage:

  • reproduces the record-deserialization failure from MSHADE-460 using Yasson;
  • verifies manifest propagation;
  • verifies root and Java 11 class and resource relocation;
  • verifies runtime selection of the relocated Java 11 resource;
  • verifies minimization across release variants; and
  • verifies removal of a versioned module descriptor.

Validation performed with JDK 17:

  • mvn clean verify — 76 tests passed;
  • mvn -Prun-its clean verify — 86 integration projects passed and one
    existing JRE-gated project was skipped.

Both generated multi-release JARs also pass JDK 21 jar --validate and execute
successfully on JDK 21.

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MSHADE-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MSHADE-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in the pull request title and in the first line of the
    commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the integration tests successfully (mvn -Prun-its clean verify).

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

Reproduce record deserialization failure when dependency multi-release semantics are lost. Cover relocation, minimization, and versioned module descriptor handling.
@wilx
wilx marked this pull request as ready for review July 31, 2026 09:47
@wilx
wilx force-pushed the issue-672-multi-release-manifest branch from f5f54f1 to 20ea8ab Compare July 31, 2026 10:07
Propagate the Multi-Release manifest attribute and relocate versioned classes and resources using their logical paths. Keep versioned classes aligned during minimization and discard versioned module descriptors just like root descriptors.

Fixes apache#672.

Fixes apache#652.

Fixes apache#463.

Fixes apache#696.
@wilx
wilx force-pushed the issue-672-multi-release-manifest branch from 20ea8ab to 9cb5813 Compare July 31, 2026 10:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant