5

I am kicking the tires on Java 12 and noticed that in javac the minimum target java level was increased to 1.7.

Execution failed for task ':com.foo:compileJava'.
> error: release version 6 not supported

Why do I want to compile to Java 6 you ask?

Even though my codebase requires a minimum java level of 1.7, I still want my kernel to be compiled at older java levels so the JVM can start up and I can output a nicer error message indicating Java 7+ must be used, instead of the more cryptic incompatible class version errors.

Looking ahead...

Java 6 is not too big of a concern, but my main concern is if Java only supports N-5 releases, by Java 14 (about a year from now) I will no longer be able to compile down to Java 8, which will probably still be a very popular runtime version.

I believe Maven can work around this sort of issue with toolchains, but does Gradle offer anything similar?

EDIT: I also noticed JEP 182, which is not approved yet, but if approved would mean only N-3 releases are supported.

Andy Guibert
  • 41,446
  • 8
  • 38
  • 61
  • if the error truly is coming from javac. Even gradle may not be able to help, as even maven and gralde use javac to compile. – Dylan Feb 18 '19 at 17:30
  • 4
    Some Gradle tasks, such as `JavaCompile`, have a [`toolChain`](https://docs.gradle.org/current/dsl/org.gradle.api.tasks.compile.JavaCompile.html#org.gradle.api.tasks.compile.JavaCompile:toolChain) property—but I've never interacted with it nor have any idea how it works. This [GitHub issue](https://github.com/gradle/gradle/issues/1652) may provide better info. – Slaw Feb 18 '19 at 17:50
  • 2
    @Andy I highly doubt the toolchains mentioned would work that way either. Using JDK12 and compiling for `source:1.6` doesn't work with `maven-compiler-plugin` in maven for sure. – Naman Feb 18 '19 at 18:05
  • 1
    I would recommend you gather more than one data point before you start extrapolating to "when are they going to take away Java 8 support." (These decisions are made, in no small part, on data about what versions people are actually using.) – Brian Goetz Mar 01 '19 at 13:18
  • @BrianGoetz so are you implying we will keep Java 8 around as a target for a while since it is widely used? If so, that would be great. However, JEP 182 has me concerned: http://openjdk.java.net/jeps/182 – Andy Guibert Mar 01 '19 at 14:50
  • 4
    @AndyGuibert I am saying that these decisions are made by intelligent humans, with benefit of adoption and usage data, who care deeply about the vibrance of the Java ecosystem, and that a naive extrapolation of "they dropped 6 support in 12, that must mean N-5", is an unwarranted conclusion. JEP 182, which set a "one and three back" policy, was in 2013, when releases were on a 2-4 year cadence (and there's a comment on the issue from the author that this clearly has to be revised for a six-month cadence.) No need to panic. – Brian Goetz Mar 01 '19 at 15:26

0 Answers0