I have a project that used JDK 8.0 before and now migrating to JDK 9. The project is not modularised yet.
All problems with closing access to private JDK API fixed and I'm able to build the project from the command line using maven, 1.8 language level and JDK 9.
Intellij Idea doesn't highlight any issues at all, JDK 9 set up as a project SDK, but if I try to build the project inside the Idea itself - I get compilation issues in the idea console:
Information:javac 9 was used to compile java sources
Error:(5, 16) java: package sun.misc does not exist
Error:(22, 19) java: cannot find symbol
symbol: class Unsafe
location: class <...>.UnsafeAccessor
So, the project is building fine in CMD using JDK 9 now, the error doesn't make too much sense because sun.misc.Unsafe exists and public in JDK 9, Idea itself doesn't highlight anything, so it understands that everything exists.
What could cause the issue for project building inside the Idea?
Info about the IDEA build:
IntelliJ IDEA 2017.2.5
Build #IU-172.4343.14, built on September 26, 2017
JRE: 1.8.0_152-release-915-b12 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13
For me, the solution was to disable the option Use '--release' option for cross-compilation' (Java 9 and later) in IDEA's Preferences, section Compiler, Java Compiler. JDK 11, IDEA 2020.1.