If a multi-release JAR file is appended to the boot class path (with the -Xbootclasspath/a option) then the JAR is treated as if it is an ordinary JAR file. Multi-release JAR files are not supported by the boot class loader of a Java runtime. Resources under the META-INF directory cannot be versioned (such as for service configuration). A future release of this specification may relax the exact same API constraint to support careful evolution. It is difficult and costly to perform extensive API verification checks as such tooling, such as the jar tool, is not required to perform extensive verification and a Java runtime is not required to perform any verification. The public API exported by the classes in a multi-release JAR file must be exactly the same across versions, hence at a minimum why versioned public or protected classes for class files under a versioned directory must preside over classes for class files under the top-level directory. If a multi-release JAR file is deployed on the class path or module path (as an automatic module or an explicit multi-release module) of major version N of a Java platform release runtime, then a class loader loading classes from that JAR file will first search for class files under the Nth versioned directory, then prior versioned directories in descending order (if present), down to a lower major version bound of 9, and finally under the top-level directory. By logical extension this applies to a class of a class file, if present, under a versioned directory whose version is less than N. If the class of the class file is public or protected then that class must preside over a class of the same fully qualified name and access modifier whose class file is present under the top-level directory. Specifically N must conform to the specification: N:Īny versioned directory whose value of N is less than 9 is ignored as is a string representation of N that does not conform to the above specification.Ī class file under a versioned directory, of version N say, in a multi-release JAR must have a class file version less than or equal to the class file version associated with Nth major version of a Java platform release. Where N is the string representation of the major version number of a Java platform release. The versioned directory is located under the the META-INF directory and is of the form: META-INF/versions/N Library and framework developers can gradually migrate to and support new Java features while still supporting the old features.Ī multi-release JAR file is identified by the main attribute: Multi-Release: trueĭeclared in the main section of the JAR Manifest.Ĭlasses and resource files dependent on a major version, 9 or greater, of a Java platform release may be located under a versioned directory instead of under the top-level (or root) directory. This enables library and framework developers to decouple the use of APIs in a specific major version of a Java platform release from the requirement that all their users migrate to that major version. For example, a multi-release JAR file can depend on both the Java 8 and Java 9 major platform releases, where some class files depend on APIs in Java 8 and other class files depend on APIs in Java 9. Multi-release JAR filesĪ multi-release JAR file allows for a single JAR file to support multiple major versions of Java platform releases. If the JAR file has a main attribute Automatic-Module-Name (see Main Attributes) then the attribute’s value is the module name, otherwise the module name is derived from the name of the JAR file as specified in ModuleFinder.of(Path.). If the modular JAR file is deployed on the class path then it behaves as if a non-modular JAR file.Ī non-modular JAR file deployed on the module path is an automatic module. Dependences and service providers are declared in the module descriptor. (Note the section on multi-release JAR files further refines the definition of modular JAR files.)Ī modular JAR file deployed on the module path, as opposed to the class path, is an explicit module. The module descriptor is the binary form of a module declaration. Modular JAR filesĪ modular JAR file is a JAR file that has a module descriptor, module-info.class, in the top-level directory (or root) directory. There is no restriction on the name of a JAR file, it can be any legal file name on a particular platform. A JAR file can be created by the command-line jar tool, or by using the API in the Java platform. A JAR file is essentially a zip file that contains an optional META-INF directory. JAR file is a file format based on the popular ZIP file format and is used for aggregating many files into one. JAR File Specification JAR File Specification
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |