Add Explicit Java Compiler Release Option #15
Labels
Improvement
Improvement of an existing feature
Java
Affects project source templates or init code for Java
Templates
Changes in project source templates
In Java-based project source templates, the
--source
and--target
compiler options are correctly set as defaults in the project's POM. However, the--release
compiler option is missing by default. It should also be added so that when compiling with a JDK version that is larger than the minimum Java version supported by the underlying project, the compiled bytecode is compatible to the minimum supported Java version.For example:
When setting up a project with support for Java 8, while using a JDK for Java > 8, then omitting the
--release
compiler option might produce bytecode which cannot be run by a JVM using Java 8. Possible example error at runtime when usingjava.nio.ByteBuffer
: ExamplePossible solution:
Add the
--release
compiler option in the affected project source template POMs.Perhaps this needs to be encapsulated in a Maven profile since that compiler option is only available in Java 9 and higher. For example, when a project still supports Java 8 and someone wants to compile it with a JDK 8 then simply setting the compiler option in the global project properties might not work.
The text was updated successfully, but these errors were encountered: