-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Description
Instead of asking users to install and use the oldest Java version supported by the project, Java 9 can be used thanks to JEP 247. Summary:
A new command-line option, --release, is defined, which automatically configures the compiler to produce class files that will link against an implementation of the given platform version. --release N is roughly equivalent to:
for N < 9: -source N -target N -bootclasspath [documented-APIs-from-N],
for N >= 9: -source N -target N --system [documented-APIs-from-N].
Expected Behavior
Similar to how one can currently set sourceCompatibility = 1.7, one should be able to set releaseCompatibility = 7 (or 1.7 maybe). If Java 9 is being used, then --release 7 (1.7 is not supported) would be passed to javac during compilation.
For older Java versions or tools that don't support --release, it probably makes sense to fallback to "--source 1.7 --target 1.7" and print a warning.
Note that IntelliJ already supports this:
"language level is automatically interpreted as -release option when compiling sources with javac 9 or newer"
https://youtrack.jetbrains.com/issue/IDEA-148501
And so does Maven:
Current Behavior
This feature is not currently supported. The easiest option at the moment is to use an older JDK. An alternative is to use -source -target and -bootclasspath, but then we need a mechanism to find the older JDK as well and write the code to set the bootclasspath. In some cases people use -source -target with a newer JDK and hope it will be OK (causing subtle issues at times).
Context
Apache Kafka still supports Java 7, so developers have to install this version even though it's no longer available from the Oracle website without a login.