Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Explicit Java Compiler Release Option #15

Closed
kilo52 opened this issue Jan 2, 2024 · 0 comments · Fixed by #16
Closed

Add Explicit Java Compiler Release Option #15

kilo52 opened this issue Jan 2, 2024 · 0 comments · Fixed by #16
Assignees
Labels
Improvement Improvement of an existing feature Java Affects project source templates or init code for Java Templates Changes in project source templates

Comments

@kilo52
Copy link
Member

kilo52 commented Jan 2, 2024

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 using java.nio.ByteBuffer: Example

Possible 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.

@kilo52 kilo52 converted this from a draft issue Jan 2, 2024
@kilo52 kilo52 self-assigned this Jan 2, 2024
@kilo52 kilo52 added Improvement Improvement of an existing feature Templates Changes in project source templates Java Affects project source templates or init code for Java labels Jan 2, 2024
@kilo52 kilo52 moved this from Open to Evaluation in Systems, Tools & Common Libraries (STCL) Jan 2, 2024
@kilo52 kilo52 moved this from Evaluation to Development in Systems, Tools & Common Libraries (STCL) Jan 5, 2024
@kilo52 kilo52 moved this from Development to Review in Systems, Tools & Common Libraries (STCL) Jan 5, 2024
@kilo52 kilo52 closed this as completed in #16 Jan 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Improvement of an existing feature Java Affects project source templates or init code for Java Templates Changes in project source templates
1 participant