Targeting Java 6 with the Java 9 JDK issues warnings

I am trying to create a project using JDK 9, since using the --release argument for javac means that it can create older versions without having to install the appropriate JDK / JRE. I need to support Java 6, so my preconfiguration requires Java 6 for bootstrapClasspath and another JDK 8 or 9 for gradle and IDE. I would like to eliminate JDK 6 in favor of just using 9 and a bit of embellishment.

My new build.gradle has the following configuration:

 tasks.withType(JavaCompile) { options.compilerArgs.addAll(['--release', '6', "-Xlint"]) } 

The sourceCompatibility , targetCompatibility and bootstrapClasspath targetCompatibility not set, as I understand that the --release argument --release processing this now.

I get the following warnings:

 warning: [options] source value 1.6 is obsolete and will be removed in a future release warning: [options] target value 1.6 is obsolete and will be removed in a future release warning: [options] To suppress warnings about obsolete options, use -Xlint:-options. 

I know that they can be suppressed (he says it right there), but I did not expect to see them. When building with --release [7-9] these warnings are absent.

For context, this is the old (not used) 2x JDK configuration:

 sourceCompatibility = "1.6" targetCompatibility = "1.6" tasks.withType(JavaCompile) { options.bootstrapClasspath = new SimpleFileCollection(Arrays.asList(new File("$JDK6_HOME/jre/lib/rt.jar"))) } 

Am I setting compiler arguments incorrectly? Is there a way to not set / unset source and target ?

+8
java java-9 release-management gradle java-10
source share
1 answer

Although this is not from an official source, the warning seems to be consistent with the β€œone plus three back” sentence, as stated in JEP182 # Policy to exit javac -source and -target Parameters

JDK 9 implements a one plus three back support policy that 1.9 / 9, 1.8 / 8, 1.7 / 7 and 1.6 / 6 will be recognized in this release. This policy will be continued in JDK 10.

Thus, ideally, 1.6 should be removed from the JDK10 in the warning image, which will be useful for clients to let them know about the policy.

Edit: However, as stated by Alan in the comments, JDK 10 will continue to support --release 6 as indicated on this mailing list.

+6
source share

All Articles