Description
I ran into a problem with building BigVolumeViewer with JDK 11 (and Maven).
pietzsch@mycroft:~/workspace/bigdataviewer/bigvolumeviewer-core (master)$ mvn clean install # 1 [15:22:38]
[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< sc.fiji:bigvolumeviewer >-----------------------
[INFO] Building BigVolumeViewer 0.3.2-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
...
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ bigvolumeviewer ---
[INFO] Compiling 103 source files to /Users/pietzsch/workspace/bigdataviewer/bigvolumeviewer-core/target/classes
[INFO] /Users/pietzsch/workspace/bigdataviewer/bigvolumeviewer-core/src/main/java/bvv/vistools/BvvFunctions.java: Some input files use or override a deprecated API.
[INFO] /Users/pietzsch/workspace/bigdataviewer/bigvolumeviewer-core/src/main/java/bvv/vistools/BvvFunctions.java: Recompile with -Xlint:deprecation for details.
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/pietzsch/workspace/bigdataviewer/bigvolumeviewer-core/src/main/java/bvv/core/blocks/ByteUtils.java:[36,16] package sun.misc does not exist
[ERROR] /Users/pietzsch/workspace/bigdataviewer/bigvolumeviewer-core/src/main/java/bvv/core/blocks/ByteUtils.java:[41,30] cannot find symbol
symbol: class Unsafe
location: class bvv.core.blocks.ByteUtils
[INFO] 2 errors
[INFO] -------------------------------------------------------------
...
This can be traced back to the maven-compiler-plugin
configuring javac
with --release 8
.
The problem is that --release 8
works slightly different that the old-style -source 1.8 -target 1.8
.
See https://bugs.openjdk.org/browse/JDK-8214165, https://bugs.openjdk.org/browse/JDK-8206937, https://mail.openjdk.org/pipermail/compiler-dev/2018-January/011583.html.
The spec for --release N
is to provide access to the public documented API for JDK N
. The sun.misc
package is not public documented API.
Ironically, if we were targeting Java 11, there would be no problem. --release 11
would work, because there is the jdk.unsupported
module ...
Anyway... I think this can be traced to
Lines 2107 to 2125 in 8920b4f
where the
<maven.compiler.release>
property is set.
The only way I found to fix that in BigVolumeViewer's pom.xml is bigdataviewer/bigvolumeviewer-core@ffaf291
https://github.com/bigdataviewer/bigvolumeviewer-core/blob/ffaf291987da4ea3e4ca9796a700b43c5209c8be/pom.xml#L83-L95
It would be nicer to address this higher up, but I don't know how pom-scijava-base should be changed exactly, and what side effects would be.