Skip to content

Multi-release JAR detection broken on Windows (File.separatorChar mismatch) #557

Description

@elharo

Bug

Multi-release JAR detection is broken on Windows because File.separatorChar is used to build the path prefix, but FileSetManager.getIncludedFiles() always returns forward-slash paths regardless of the operating system.

Location

AbstractJarMojo.java:248-249:

p -> p.startsWith("META-INF" + File.separatorChar + "versions" + File.separatorChar)

On Windows, File.separatorChar is \, so the prefix becomes META-INF\versions\, which never matches the forward-slash paths returned by FileSetManager (e.g. META-INF/versions/9/module-info.class).

Effect

The Multi-Release: true manifest entry is never added for multi-release JARs when the build runs on Windows. The JAR is still created but lacks the manifest entry, so the JVM will not use versioned classes from META-INF/versions/.

Fix

Replace File.separatorChar with the forward slash character "/". JAR paths always use forward slashes per the JAR specification, and FileSetManager normalizes to forward slashes on all platforms.

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