GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — maven-jar-plugin can create invalid Multi-Release jars · Issue #484 · apache/maven-jar-plugin

maven-jar-plugin can create invalid Multi-Release jars #484

New issue
Copy link
New issue
Copy link
Open
Open
maven-jar-plugin can create invalid Multi-Release jars#484
Copy link
Labels
bugSomething isn't working

Description

@cushon
cushon
opened on Oct 15, 2025
Issue body actions

Affected version

3.4.2

Bug description

When maven-jar-plugin is used to create a Multi-Release jar, it doesn't check that the jars are valid.

The jar tool will validate that the APIs of all versioned classes are the same, and report an error like the following if they are not

entry: META-INF/versions/.../Foo.class, contains a class with different api from earlier version
invalid multi-release jar file ... deleted

Since JDK 17 (JDK-8266835), the jar tool supports a --validate flag that can be used to validate archives created by other tools. So one option would be to re-use that, or have a recommended way to run jar --validate on the outputs of maven-jar-plugin.

Here are two examples where this came up with jars created by maven-jar-plugin

  • Use jar, not maven-jar-plugin, to create MR-JAR unitsofmeasurement/indriya#348
  • JdkClassWriter APIs are out of sync, rejected by jar raphw/asm-jdk-bridge#11

Activity

  1. cushon
    added
    bugSomething isn't working
    on Oct 15, 2025
  2. desruisseaux commented on Oct 15, 2025

    @desruisseaux
    desruisseaux
    on Oct 15, 2025
    More actions

    Yes, I plan to work on that. Following the recent work merged on the compiler plugin, I propose to upgrade the JAR plugin to the JPMS world as well. This work would imply using the jar tool provided by javax.tools API rather than zipping the file ourselves. In my understanding of JDK-8266835, the jar tool already verifies the validity of the multi-release file when these files are created with the --release option rather than zipping ourselves the content of META-INF/versions/. Therefore, we would not need to run jar --validate afterwards.

    Reacted by Liam Miller-Cushon
  3. desruisseaux commented on Nov 10, 2025

    @desruisseaux
    desruisseaux
    on Nov 10, 2025
    More actions

    Would be fixed by #495 if accepted.

  4. desruisseaux
    added a commit that references this issue on Aug 27, 2026

    Execute `jar --validate` only if requested.

    245dcb2
  5. gnodet commented on Sep 25, 2026

    @gnodet
    gnodet
    on Sep 25, 2026
    Contributor
    More actions

    This is being worked on in #508, which is a major refactoring of the plugin to use the standard jar tool via java.util.spi.ToolProvider instead of Maven Archiver. Since the jar tool performs consistency checks when building multi-release JARs (using the --release option), this will naturally fix the issue. The PR is scoped to maven-jar-plugin 4.x / Maven 4 + Java 17.

  6. desruisseaux commented on Nov 28, 2026

    @desruisseaux
    desruisseaux
    on Nov 28, 2026
    More actions

    Can we close this issue as resolved with Maven JAR plugin 4.0.0-beta-2 released last month?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.