On 30/12/2022 19:11, Glavo wrote:
I agree that it is a good choice to use -release or set bootclasspath. However, this is not always realistic.

Using -release means that we will encounter many JPMS problems.
For example, using --add-exports for system modules is not allowed when using -release.

This combination of options doesn't make sense. If you are going off piste and compiling against JDK internal classes then you'll need to have that JDK present on your file system. A release number maps to the language and APIs in that release, it can't be expected to know about JDK internal classes that happen to be a JDK build as they can vary and shimmer by vendor or update. Maybe if you could expand a bit on what you are doing so it can help you avoid the configuration issue in your build.



In addition, sometimes we may want to deliberately bypass the restriction of -release:
We may use some new APIs of higher Java versions in our code.
As long as we check the Java version at runtime and ensure that the code path is not executed
when running on a lower version of Java, this is also reasonable.

This reads like you want to compile to --release 8 but have static references in version 52 class files to APIs that were added in Java 9+, is that right? This may be a setup for a world of hurt and maybe you should explore Multi-Release JAR files for this.

-Alan

Reply via email to