Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

pi4j doesn't compile with java 9 #404

Closed
bsutton opened this issue Mar 1, 2018 · 4 comments · Fixed by #522
Closed

pi4j doesn't compile with java 9 #404

bsutton opened this issue Mar 1, 2018 · 4 comments · Fixed by #522
Assignees
Milestone

Comments

@bsutton
Copy link
Contributor

bsutton commented Mar 1, 2018

I've just upgraded to java 9 and when trying to build pi4j got the following errors:

pi4j-core/src/main/java/com/pi4j/io/file/LinuxFile.java:[34,16] cannot find symbol
symbol: class Cleaner
location: package sun.misc
pi4j-core/src/main/java/com/pi4j/io/file/LinuxFile.java:[35,16] cannot find symbol
symbol: class SharedSecrets
location: package sun.misc
pi4j/pi4j-core/src/main/java/com/pi4j/io/file/LinuxFile.java:[215,32] cannot find symbol
symbol: variable SharedSecrets
location: class com.pi4j.io.file.LinuxFile
pi4j-core/src/main/java/com/pi4j/io/file/LinuxFile.java:[313,15] cannot find symbol
symbol: class Cleaner
location: class com.pi4j.io.file.LinuxFile

@albahrani
Copy link

With JDK9 access to the sun-packages has been restricted by default.
You may use the -jdkinternals flag when compiling to get it working without change right now.
On the long run the following should be done:

  • Replace uses of sun.misc.Cleaner with java.lang.ref.Cleaner in LinuxFile.java
  • Replace uses of sun.misc.SharedSecretswith jdk.internal.misc.SharedSecrets in LinuxFile.java

@pg-adm1n
Copy link

@albahrani There should be jdk.internal.ref.Cleaner instead of java.lang.ref.Cleaner

@agilkes
Copy link

agilkes commented Aug 4, 2018

In LinuxFile.java, I have replaced the "sun.misc" imports with imports of jdk.internal.misc.SharedSecrets and jdk.internal.ref.Cleaner. But when I "build" the pi4j.core project in Eclipse, the Java compiler (10.0.2) gives me "is not accessible" error messages for both imports. These result in 3 other compiler error messages that appear later in LinuxFile.java. How do you get the Java compile to succeed?

@pg-adm1n
Copy link

pg-adm1n commented Aug 5, 2018

@agilkes You should add compiler parameters "--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED --add-exports=java.base/jdk.internal.misc=ALL-UNNAMED"

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

Successfully merging a pull request may close this issue.

5 participants