Skip to content

Choose the versioned module descriptor by the target release, not the running JDK #237

Description

@slachiewicz

AbstractBinaryModuleInfoParser picks the versioned descriptor of a multi-release jar, and since #236 of a multi-release output directory, by counting down from the version of the JDK that runs the build. The version that matters is the one the code is compiled for:

  • On a Java 8 runtime compiling through a Java 9+ toolchain (Maven 3.9 on JDK 8), META-INF/versions/<N>/module-info.class is never found, so the jar or directory is treated as a filename-based automatic module or put on the classpath.
  • On a newer runtime compiling with a lower --release, a descriptor from a version above that release can be picked.

Proposal: add a release (or Java version) setting to ResolvePathsRequest, defaulting to the running JDK, and pass it to getModuleDescriptor(Path, JavaVersion) and to the directory check in LocationManager.resolvePath. Callers such as maven-compiler-plugin would set it from release/target.

Activity

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

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions