JDK 13 RFR of JDK-8221264: Refactor SourceVersion#latestSupported
Alan Bateman
Alan.Bateman at oracle.com
Sun Mar 24 19:40:05 UTC 2019
On 24/03/2019 16:20, Martin Buchholz wrote:
> Here's a naive user journey into upgradeable module land:
>
> I knew about upgradeable modules from reading JEP 261 but I had
> trouble figuring out which modules in a particular JDK were
> upgradeable. How does one tell that java.compiler is upgradeable in a
> particular JDK?
The modules for the standalone technologies are upgradable. Prior to
Java SE 9 the list was documented on the "Endorsed standards override
mechanism" page, From Java SE 9 on, the standard modules document it
themselves in their module description. As of Java SE 11, the only
standard module that is upgradeable is java.compiler, upgradeable
because it exports the APIs defined by JSR 199 and 269.
There hasn't been a need to date to have one place list the modules in
the JDK that are upgradeable but the output from your script looks right
(you can check it against the value of UPGRADEABLE_MODULES in
make/common/Modules.gmk). The reason that the modules containing the
Graal bits are upgradable is so that builds from the upstream Graal
project can be used with a JDK build.
One other thing to know is that the non-upgradable modules are strongly
tied to java.base, essentially a SHA-256 hash of each of non-upgradable
modules is stored in java.base to prevent accidental mixing of modules
from different builds. This enforcement is mostly applicable at
link-time, as in jlink.
> :
>
> If the class files for upgradeable modules were built to target an
> older JDK version, they could be used unchanged in JDK(N) or JDK(N-1).
> If additionally there was a way to turn a .jmod file into a modular
> jar, that artifact could be used directly in JDK(N-1)
>
> Many people in the industry are migrating across LTS releases jdk8 ->
> jdk11 -> jdk17.
> They will want to use jdk17 java.compiler in an IDE running on jdk11.
>
> $ jver 11 jmod describe java.compiler.jmod
> Error: Unsupported major.minor version 57.0
>
If an IDE maker wants to upgrade the java.compiler module then they will
be building the javax.tools and javax.lang.model APIs for the JDK
release that the IDE uses. They will need a compiler implementation too,
maybe loading it into a module layer as jdk.compiler is not upgradeable.
There should be no expectation that they can take the contents of
java.compiler.jmod from a newer release.
-Alan
More information about the compiler-dev
mailing list