javac
can recognize and process class files of all previous JDKs, going all the way
back to JDK 1.0.2 class files.
See JEP 182: Policy for Retiring javac -source and -target Options.
• Critical internal JDK APIs such as sun.misc.Unsafe are still accessible in JDK
9, but most of the JDK’s internal APIs are not accessible at compile time. You may
get compilation errors that indicate that your application or its libraries are
dependent on internal APIs.
To identify the dependencies, run the Java Dependency Analysis tool. See Run
jdeps on Your Code. If possible, update your code to use the supported
replacement APIs.
You may use the
--add-exports
option as a temporary workaround to compile
source code with references to JDK internal classes.
• You may see more deprecation warnings than previously. If you see deprecation
with removal warnings, then you should address those to avoid future problems.
• A number of small changes have been made to
javac
to align it with the Java SE 9
Language Specification.
• You may encounter some source compatibility issues when recompiling.
The JDK 9 Release Notes contains details of changes to the
javac
compiler and
source compatibility issues in JDK 9.
Run jdeps on Your Code
Run the
jdeps
tool on your application to see what packages and classes your
applications and libraries depend on. If you use internal APIs, then
jdeps
may suggest
replacements to help you to update your code.
To look for dependencies on internal JDK APIs, run
jdeps
with the
-jdkinternals
option. For example, if you run
jdeps
on a class that calls
sun.misc.BASE64Encoder
,
you’ll see:
>jdeps -jdkinternals Sample.class
Sample.class -> JDK removed internal API
Sample -> sun.misc.BASE64Encoder JDK internal API (JDK removed internal API)
Warning: JDK internal APIs are unsupported and private to JDK implementation that are
subject to be removed or changed incompatibly and could break your application.
Please modify your code to eliminate dependency on any JDK internal APIs.
For the most recent update on JDK internal API replacements, please check:
https://wiki.openjdk.java.net/display/JDK8/Java+Dependency+Analysis+Tool
JDK Internal API Suggested Replacement
---------------- ---------------------
sun.misc.BASE64Encoder Use java.util.Base64 @since 1.8
If you use Maven, there’s a
jdeps
plugin available.
For
jdeps
syntax, see
jdeps
in the Java Platform, Standard Edition Tools Reference.
4