Skip to content

[MSHADE-265] - Add module-info merging support - #829

Open
wilx wants to merge 1 commit into
apache:masterfrom
wilx:issue-629-module-info-merging
Open

[MSHADE-265] - Add module-info merging support#829
wilx wants to merge 1 commit into
apache:masterfrom
wilx:issue-629-module-info-merging

Conversation

@wilx

@wilx wilx commented Jul 30, 2026

Copy link
Copy Markdown

Summary

Add opt-in merging of Java module descriptors with:

<moduleInfoMode>merge</moduleInfoMode>

The default remains discard, preserving the plugin's existing behavior.

The merge follows a source-amalgamation model: the primary artifact supplies the
module identity, while the shaded contents are treated as if their sources had
been relocated and compiled into that module. By default, the primary module's
exports and opens remain its public boundary. Users can opt into the effective
boundary of embedded modules or add explicit exports, opens, requirements, and
service uses where source-level intent cannot be inferred safely.

The processor:

  • removes requirements on modules absorbed into the shaded artifact;
  • uses only each release view's configured embedded identity, preserving external
    requirements that collide with inactive descriptor or filename-derived names;
  • preserves open-module semantics by emitting no explicit opens for an open primary
    and materializing retained packages from embedded open modules when boundary
    merging is requested;
  • infers external reads and service declarations from embedded explicit and
    automatic modules;
  • applies configured relocations to packages, classes, providers, and services;
  • analyzes automatic-module bytecode and service configuration, failing with
    actionable guidance when dynamic service use cannot be inferred;
  • selects automatic-module analysis from the same filtered, release-aware
    descriptor view used for merging;
  • resolves platform ownership against ct.sym and jmods from a selected JDK,
    with optional toolchain requirements for release-aware analysis; and
  • fails when filtering or minimization would leave an invalid module descriptor.

Multi-release inputs are merged as cumulative release views. The implementation
rebuilds ModulePackages, validates the invariants required of versioned module
descriptors, and raises the modular floor when a provider or public-boundary
change cannot be represented at an earlier release. Earlier releases then retain
an automatic-module bridge with a stable Automatic-Module-Name.

Manifest processing now also accepts reactor output directories. Maven can expose
a reactor dependency as target/classes when separate lifecycle tasks such as
package test are requested. The manifest pre-scan reads a directory manifest
when present, instead of attempting to open the directory as a JAR.

Documentation covers the defaults, public-boundary modes, explicit overrides,
toolchain selection, dynamic service use, and modular-floor behavior.

Fixes #629.

Fixes #581.

Fixes #588.

JIRA: MSHADE-265,
MSHADE-215

Validation

  • mvn test: 104 tests run, zero failures; one skipped.
  • JDK 8 mvn test: 104 tests run, zero failures; 14 modular-runtime tests skipped.
  • mvn -Prun-its verify: 86 integration projects passed, one skipped by its
    JRE-version condition.
  • The focused module-info-merge project passed when the built plugin was run
    with Maven 3.6.3, current Maven 3.x, and Maven 4.
  • The focused MSHADE-215 project fails with Shade 3.6.2 and passes with the
    branch build under Maven 3.6.3, current Maven 3.x, and Maven 4.
  • The original MSHADE-215 reproducer failed under Wine 9 with a Windows Temurin
    21 JVM and Maven 3.9.16; the branch build completed successfully in the same
    environment.
  • mvn site passed.
  • The generated modular JAR passed jar --validate, jar --describe-module,
    and jdeps --check.

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.

@wilx
wilx marked this pull request as ready for review July 30, 2026 18:24
@wilx
wilx force-pushed the issue-629-module-info-merging branch 2 times, most recently from 6cbc929 to 38ac043 Compare July 30, 2026 19:38
@wilx
wilx marked this pull request as draft July 30, 2026 20:39
@wilx
wilx force-pushed the issue-629-module-info-merging branch 4 times, most recently from 90dc6e4 to 4cb31a5 Compare July 30, 2026 22:25
@wilx
wilx marked this pull request as ready for review July 30, 2026 22:29
@wilx
wilx force-pushed the issue-629-module-info-merging branch from 4cb31a5 to ea84628 Compare July 31, 2026 12:05
Add opt-in merging for root and multi-release module descriptors while preserving the primary module boundary. Cover relocation, services, modular-floor handling, filtering failures, Maven 3/4 compatibility, and reactor output directories during manifest processing.

Fixes apache#629.

Fixes apache#581.

Fixes apache#588.
@wilx
wilx force-pushed the issue-629-module-info-merging branch from ea84628 to 82abdc8 Compare July 31, 2026 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment