Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using --release compiler option vs -source and -target #34

Open
tpietzsch opened this issue Aug 23, 2023 · 0 comments
Open

Using --release compiler option vs -source and -target #34

tpietzsch opened this issue Aug 23, 2023 · 0 comments

Comments

@tpietzsch
Copy link
Member

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

pom-scijava-base/pom.xml

Lines 2107 to 2125 in 8920b4f

<profile>
<id>java-9</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<properties>
<maven.compiler.release>${scijava.jvm.version}</maven.compiler.release>
</properties>
<build>
<plugins>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
</configuration>
</plugin>
</plugins>
</build>
</profile>

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant