[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Gradle and JDK 11 issues



On 03/11/2018 23:36, Markus Koschany wrote:

> I have fixed it like that in mockito but it still feels like a
> regression to me. sourceCompatibility and targetCompatibility had been
> already set in build.gradle but now with OpenJDK 11 I have to specify it
> in two other .gradle files as well. Maybe this is magically resolved in
> a later Gradle version.

It looks like Gradle uses the current Java version when compiling a
project not specifying the source/target level explicitly, and it does
so by passing the -source and -target options to javac with a 1.x value,
where x is the version of the JDK targeted. The issue is, up to Java 10
javac accepted the values 1.x and x, but starting with Java 11 it no
longer accepts the 1.x values (for x >= 11).

So with Java 11, we can still do:

  javac -source 1.10 -target 1.10 Foo.java

but not:

  javac -source 1.11 -target 1.11 Foo.java

This returns the error "invalid source release: 1.11". The following
syntax has to be used instead:

  javac -source 11 -target 11 Foo.java

This is very likely to be fixed in a recent Gradle update, but upgrading
the gradle package won't be possible before the Buster release. So
either someone figures out a patch for Gradle 4.4.1, or we simply add
two lines to the few affected packages.

Emmanuel Bourg


Reply to: