-
Notifications
You must be signed in to change notification settings - Fork 182
Description
Liam Miller-Cushon opened MCOMPILER-596 and commented
This is a feature request to support configuring javac's --system flag: https://docs.oracle.com/en/java/javase/21/docs/specs/man/javac.html#option-system
-system can be set to the path to a JDK, and configures javac to read system APIs from that JDK. For example, when using javac from JDK 21 you could set -source 11 -target 11 --system <path to JDK 11> to compile Java 11 code. This is similar to setting –release 11, but supports use-cases that –release doesn't, for example –system (but not –release) can be combined with passing -add-exports= to javac.
One alternative is to use toolchains and <fork>true</fork> to run on a different javac version corresponding to the target JDK version, which will implicitly use that JDK's APIs. However using fork is slower, and it requires using an older javac version. Using the latest javac version and cross-compiling with --system can be beneficial to get the latest compiler version and benefit from bug fixes and improvements in the latest versions of javac.
As a straw-person configuration proposal, ideally system could be configured by referring to a jdk toolchain, for example with:
<configuration>
<system>
<version>11</version>
<vendor>zulu</vendor>
</system>
</configuration>
1 votes, 3 watchers