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

Re: Bug#895619: plexus-compiler: use --release instead of -source/-target for jdk9+ when setting defaults

Le 13/04/2018 à 17:14, Tiago Stürmer Daitx a écrit :

> plexus-compiler currently will default -source and/or -target to 1.7
> whenever the following occours:
> 1) whenever either has not being set
> 2) whenever either has been set to 1.6 or earlier
> This patch modifies the detection logic in order to be able to set the
> '--release' flag when (and only when):
> - the '--release' is *not* set
> - AND both -source and -target are being set to a default value
> - AND the running jvm is jdk9 or newer
> This prevents errors such as the infamous "Method
> flip()Ljava/nio/ByteBuffer; does not exist in class java.nio.ByteBuffer"
> that is caused by building with openjdk-9 with -source set without
> setting the proper bootclasspath [1,2]. JEP-247 [3] has provided the
> --release to prevent such issues and should be used instead of -source
> whenever the javac being used is jdk9 or higher.

Setting the --release option automatically is now implemented in Maven
(since plexus-compiler/2.8.4-1) and Ant (since ant/1.10.3-2), and it
triggers a new issue unfortunately. When the --release option is set the
internal JDK APIs (com.sun.*, sun.misc.*) are no longer available, and
this breaks several packages (axis for example, see #902861). The same
code compiles fine with '-source <n> -target <n>' though.

I'm not sure we can fix all the errors reported and we may have to
revert the use of the --release option in Ant/Maven. That would mean the
packages built with OpenJDK 10/11 are unlikely to run with OpenJDK 8
(the binary incompatibility in the ByteBuffer class affects quite a lot
of code).

Someone has a better idea?

Emmanuel Bourg

Reply to: