[
https://issues.apache.org/jira/browse/MCOMPILER-596?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Liam Miller-Cushon updated MCOMPILER-596:
-----------------------------------------
Description:
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>}}
was:
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>}}
> Support configuring javac's --system flag
> -----------------------------------------
>
> Key: MCOMPILER-596
> URL: https://issues.apache.org/jira/browse/MCOMPILER-596
> Project: Maven Compiler Plugin
> Issue Type: New Feature
> Reporter: Liam Miller-Cushon
> Priority: Major
>
> 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>}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)