Java Modules and Multi-Release Jar
Luke Hutchison
luke.hutch at gmail.com
Sun Sep 30 07:57:14 UTC 2018
On Sun, Sep 30, 2018, 1:35 AM Alan Bateman <Alan.Bateman at oracle.com> wrote:
> I don't recall the discussion here that lead to the advice to put the
> module-info.class in META-INF/versions/9 - if you can find the mail
> thread or even the subject line of the discussion then it would help
> provide the context. In general, the reason to use a MR JARs is where
> you are targeting a range of JDK releases and you want to take advantage
> of newer APIs on newer releases. Yes, it is possible to have the
> module-info.class in the versioned section for the super advanced case
> where code in META-INF/versions/10 or META-INF/versions/11 has
> additional dependences or makes use of services that the code in the
> base section doesn't but I suspect that isn't the case here. Whether the
> module-info.class is in the top-level directory or META-INF/versions/9
> shouldn't matter of course, except when running into libraries or tools
> that can't handle MR JARs.
>
I have a related question about this specifically. I just added
multi-release jar support to ClassGraph (
https://github.com/classgraph/classgraph ). If one or more versioned
sections are present and the code is running on JRE9+, then the
highest-numbered section number less than or equal to the running JRE
version is scanned, and the other sections (including the base section) is
ignored by ClassGraph. Does this more or less match the JRE semantics, or
should I be rather using the versioned section to shadow/mask the base
section, but scan / read from both?
ie. does the JRE find resources and classes in both the versioned section
and the base section, or does the presence of a versioned section preclude
reading from the base section? Your comments seem to indicate the former,
since it sounds like module-info.class can be in either the versioned
section or the base section, and if it is in the base section, that means
module-info.class applies to all versions. That could mean that the base
section shadows the version sections, not the other way around (at least
for module-info.class).
More information about the jigsaw-dev
mailing list