Summary: | java-pkg-simple.eclass: Support building multi-release JAR files [JEP 238] | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Yuan Liao (Leo3418) <liaoyuan> |
Component: | Eclasses | Assignee: | Java team <java> |
Status: | CONFIRMED --- | ||
Severity: | normal | ||
Priority: | Normal | ||
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Yuan Liao (Leo3418)
2023-03-08 22:15:44 UTC
Extra Information That May Be Useful to This Functionality's Implementation Summary of the multi-release JAR file standard: - Definitions: - Multi-release JAR file: A JAR file in which the META-INF/MANIFEST.MF file bears the line: Multi-Release: true - Versioned directory: A 'META-INF/versions/<N>' directory in a multi-release JAR file, where <N> is the Java major release number (9, 10, 11, ..., 17, ...) that files under this directory target. - Requirements: - "The public API exported by the classes in a multi-release JAR file must be exactly the same across versions". Interpretation: This eliminates the possibility where a class that is part of a public API is only available on certain latest Java major releases and not on older releases. The public API's implementation may alter between different Java major releases to utilize the releases' latest features, but the API's interface may not. The 'jar' tool itself naturally supports building a multi-release JAR file <https://docs.oracle.com/en/java/javase/17/docs/specs/man/jar.html>: --release VERSION Creates a multirelease JAR file. Places all files specified after the option into a versioned directory of the JAR file named META-INF/versions/VERSION/, where VERSION must be must be a positive integer whose value is 9 or greater. At run time, where more than one version of a class exists in the JAR, the JDK will use the first one it finds, searching initially in the directory tree whose VERSION number matches the JDK's major version number. It will then look in directories with successively lower VERSION numbers, and finally look in the root of the JAR. The same page also provides an example invocation of 'jar' that builds a multi-release JAR file under the "Examples of jar Command Syntax" section. Build systems like Maven and Gradle have been supporting building multi-release JAR files already: - Maven: https://maven.apache.org/plugins/maven-compiler-plugin/multirelease.html - Gradle: https://blog.gradle.org/mrjars#how-to-create-a-multi-release-jar-with-gradle |