- Loading...
...
JDK 9 has not been released yet. That means the tips and suggestions accumulated here should not be taken as the final word on how to adjust your code for JDK 9 as some things may (and probably will) change as the set of JEPs targeted for JDK 9 changes. If in doubt, ask - preferably on the adoption-discuss mailing list.
This page does not provide a comprehensive list of planned or targeted JDK 9 features. For an up to date list of JEPs targeted for JDK 9, please consult the JDK 9 Project page.
...
JDK 9 Early Access builds may also be provided by third parties. Oracle publishes regular JDK 9 builds at http://jdk9jdk.java.net/9, for example. In the same location, Oracle also publishes regular JDK 9 builds based on the latest Project Jigsaw source code at httpshttp://jdk9jdk.java.net/jigsaw/.
If your application's startup script launches the JDK 9 JVM with an unrecognized VM option, it will exit and let you know that it couldn't create a VM because of that unrecognized VM option. Some of the VM flags that were deprecated in JDK 8, have been removed in JDK 9 - like those relating to the permanent generation, which was removed in JDK 8.
For example, if your application's startup script attempts to launch the JDK 9 JVM providing an unrecognized -XX:MaxPermSize=256m option, the JDK 9 JVM will exit with an error message:
Unrecognized VM option 'MaxPermSize=256m'Error: Could not create the Java Virtual Machine.Error: A fatal exception has occurred. Program will exit.In JDK 8 a new Java Dependency Analysis Tool (jdeps) was added to help developers understand the static dependencies of their applications and libraries. It can help you find dependencies on any internal, unsupported or private APIs that your application or its libraries use. A program using such APIs is not guaranteed to work in future versions of JDK 9 or even the same platform. For more information, please see this document.
A jdeps plugin for Apache Maven exists.
For best results, please make sure to run jdeps from the most recent JDK 8 update release or JDK 9 Early Access build.
Third-party libraries that encounter issues on JDK 9 may have had those issues fixed meanwhile as their developers begun to test with JDK 9 and address problems found. If you encounter issues with third party libraries, please check if there is a newer version that addresses them, and update your code to depend on the newer version.
For example, if your application uses Eclipse RCP 4.4 or below, it may exit with an error message on JDK 9:
java.lang.NoClassDefFoundError: org/w3c/dom/stylesheets/StyleSheetEclipse RCP 4.5 contains a fix for that issue.
In order to use javac to cross-compile to an older release of the platform it is not sufficient to just set the -source and -target options to the older value; the bootclasspath must also be set to correspond to the older release too. Setting the bootclasspath is sometimes forgotten, potentially leading to obscure errors at runtime.
In JDK 9, the new -release flag in javac addresses both of these shortcomings. Now only a single flag (-release) needs to be set to cross compile compared to three flags (-source, -target, -bootclasspath) and the needed information is included in the JDK.
In general, it's simpler to start by building your code in your familiar build environment, and test it by running it on JDK 9, than to start by building it on JDK 9. The tools and libraries used in your build process might themselves not yet have been tested with JDK 9 by their developers.
Some of the changes targeted for JDK 9 may affect code that relies on default, deprecated, removed, unsupported, internal or unspecified functionality. The list below has been compiled from the list of JEPs targeted for JDK 9 and other resources. It is not an exhaustive list of changes - there may be other changes you run into that have not been listed here.
Where available, the list provides links to further resources, like JEPs, mailing list threads or JBS issues.
JEP 249 may affect code connecting to TLS servers that cannot accept the status_request or status_request_v2 TLS extensions. It implements OCSP stapling via the TLS Certificate Status Request extension (section 8 of RFC 6066) and the Multiple Certificate Status Request Extension (RFC 6961). The OCSP stapling feature will be enabled by default in the JDK with this implementation.
JEP 238 may affect code implementing runtimes with class loaders using ZipFile to load classes, instead of using the URL class loader or a custom class loader leveraging JarFile to obtain platform-specific class files. Such code will not be multi-release JAR file aware.
.
In JDK 8 a new Java Dependency Analysis Tool (jdeps) was added to help developers understand the static dependencies of their applications and libraries. It can help you find dependencies on any internal, unsupported or private APIs that your application or its libraries use. A program using such APIs is not guaranteed to work in future versions of JDK 9 or even the same platform. For more information, please see this document.
A jdeps plugin for Apache Maven exists.
For best results, please make sure to run jdeps from the most recent JDK 8 update release or JDK 9 Early Access build.
Third-party libraries that encounter issues on JDK 9 may have had those issues fixed meanwhile as their developers begun to test with JDK 9 and address problems found. If you encounter issues with third party libraries, please check if there is a newer version that addresses them, and update your code to depend on the newer version.
For example, if your application uses Eclipse RCP 4.4 or below, it may exit with an error message on JDK 9:
java.lang.NoClassDefFoundError: org/w3c/dom/stylesheets/StyleSheetEclipse RCP 4.5 contains a fix for that issue.
In order to use javac to cross-compile to an older release of the platform it is not sufficient to just set the -source and -target options to the older value; the bootclasspath must also be set to correspond to the older release too. Setting the bootclasspath is sometimes forgotten, potentially leading to obscure errors at runtime.
In JDK 9, the new -release flag in javac addresses both of these shortcomings. Now only a single flag (-release) needs to be set to cross compile compared to three flags (-source, -target, -bootclasspath) and the needed information is included in the JDK.
In general, it's simpler to start by building your code in your familiar build environment, and test it by running it on JDK 9, than to start by building it on JDK 9. The tools and libraries used in your build process might themselves not yet have been tested with JDK 9 by their developers.
Some of the changes targeted for JDK 9 may affect code that relies on default, deprecated, removed, unsupported, internal or unspecified functionality. The list below has been compiled from the list of JEPs targeted for JDK 9 and other resources. It is not an exhaustive list of changes - there may be other changes you run into that have not been listed here.
Where available, the list provides links to further resources, like JEPs, mailing list threads or JBS issues.
JEP 249 may affect code connecting to TLS servers that cannot accept the status_request or status_request_v2 TLS extensions. It implements OCSP stapling via the TLS Certificate Status Request extension (section 8 of RFC 6066) and the Multiple Certificate Status Request Extension (RFC 6961). The OCSP stapling feature will be enabled by default in the JDK with this implementation.
JEP 238 may affect code implementing runtimes with class loaders using ZipFile to load classes, instead of using the URL class loader or a custom class loader leveraging JarFile to obtain platform-specific class files. Such code will not be multi-release JAR file aware.
JEP 236 may affect code that uses internal classes JEP 236 may affect code that uses internal classes in the jdk.nashorn.internal.ir package and its sub-packages.
...
JDK-8148651 may affect code that needs to process class files. Anyone writing tools and libraries for use on JDK 9 that process class files should update their code to handle the new version number. Code using such rtools tools and libraries should be updated to a version that supports v53 class files.
...
JEP 229 may affect code that uses keystores. It changes the default keystore type from JKS to PKCS12. By default, new keystores will be created in the PKCS12 keystore format. Existing keystores will not change and keystore applications can continue to explicitly specify the keystore type they require.
JEP 288 may affect code that uses X.509 certificate chains with SHA-1 based signatures.
JEP 283 may affect graphical applications on Linux. In cases where GTK 3 is required for interoperability, and this requirement can be detected sufficiently early, GTK 3 will be enabled automatically.
...
JEP 226 may affect code that loads property files. It defines a means for applications to specify property files encoded in UTF-8, and extends the ResourceBundle API to load them by default.
JDK-8143404 may affect code that relies on the removed AppleScript engine.
...
Users who are using any of the flags that are being removed will have to update their JVM-startup command lines. If they are moving from JDK 8 to JDK 9 then they will already have seen warning messages and thus should not be surprised. For a detailed list of the flags and flag combinations that have stopped working in JDK 9, please consult the JEP text.
JDK-8066750 may affect code that relies on the removed HTTP Proxy implementation in RMI.
JEP 231 may affect code that relies on the removed ability to request, at JRE launch time, a version of the JRE that is not the JRE being launched.
JDK-6512052 may affect code that relies on the removed java-rmi.exe launcher.
...
JDK-8029904 may affect code that uses the com.sun.security.auth.callback.DialogCallbackHandler, which was deprecated in JDK 8, and removed in JDK 9.
JDK-7067728 may affect code that relies on the removed stopThread RuntimePermission from the default java.policy.
JDK-8134808 may affect code that relies on support for serialized applets.
JEP 217 may affect source code that uses annotations due to the refactoring of the javac annotation pipelineJEP 217 may affect source code that uses annotations due to the refactoring of the javac annotation pipeline, which should not be externally noticeable except where bugs were fixed and correctness improved.
...
JEP 217 may affect source code that uses the applet API. The deprecation annotations will cause deprecation warnings to be emitted by the Java compiler for all code that uses this API. If warnings are treated as errors, they will result in build failure.
...
JEP 224 may 277 may affect source code with Javadoc comments since the -Xdoclint feature of javadoc will be modified to validate input comments based upon the requested markup.
JEP 213 may affect source code that uses underscore ("_") as an identifier. Its use generated a warning as of Java SE 8, and has been turned into an error in JDK 9.
JEP 275 may affect code that uses the javapackager tool. The packager will only create applications that use the JDK 9 runtime.
JEP 261 may affect source code that is not compiled with the javac compiler using the -source, -target or -release options to select the use of legacy mode.
The stack traces generated for exceptions at run time have been extended to include, when present, the names and version strings of relevant modules. The detail strings of exceptions such as ClassCastException,IllegalAccessException, and IllegalAccessError have also been updated to include module information. Any code analysing, or filtering, based on the stack trace element's detail strings should be updated appropriately, to handle this.
In addition, this feature may affect code that assumes that the application class loader or the extension class loader is an instance of URLClassLoader, rather than of an internal class.
This feature may also affect code that attempts to set or read the bootclasspath using the -Xbootclasspath or the -Xbootclasspath/p options, or the removed JDK-specific system property sun.boot.class.path.
Changes due primarily to the introduction of the Java Platform Module System may affect code which
public modifier to an API element guarantees that the element will be everywhere accessible, or ClassLoader::getResource* and Class::getResource* methods to read JDK-internal resources, orjava.lang.reflect.AccessibleObject::setAccessible method to gain access to members of packages that are not exported by their defining modules, orExisting code that invokes ClassLoader::getSystemClassLoader and blindly casts the result to URLClassLoader, or does the same thing with the parent of that class loader, might not work correctly.
Existing custom class loaders that delegate directly to the bootstrap class loader might not work correctly; they should be updated to delegate to the extension class loader.
The five-parameter transform method declared in thejava.lang.instrument.ClassFileTransformer interface is now a default method.
Existing code that scans for META-INF/services resource files previously found in rt.jar and other internal artifacts which are not present in the corresponding system modules files might not work correctly.
The JDK-specific system property file.encoding can be set on the command line via the -D option, as before, but it will only work when it specifies a charset defined in the base module. Existing launch scripts that specify other charsets might not work correctly.
JDK-8011044 may affect source code that uses javac -source or -target options below 6/1.6 to compile.
JEP 221 may affect code that uses the Doclet API. It replaces the Doclet API with a simpler design that leverages newer alternative APIs with improved functionality, and updates the standard doclet to use it.
that uses a deprecated Java SE API. Several Java SE APIs will have a @Deprecated annotation added, updated, or removed. Deprecating APIs will increase the number of mandatory warnings that projects encounter when building against newer versions of Java SE. For more information about these planned changes, please consult the JEP text.
JEP 224 may affect source code with Javadoc comments since the -Xdoclint feature of javadoc will be modified to validate input comments based upon the requested markup.
JEP 213 may affect source code that uses underscore ("_") as an identifier. Its use generated a warning as of Java SE 8, and has been turned into an error in JDK 9.
JEP 275 may affect code that uses the javapackager tool. The packager will only create applications that use the JDK 9 runtime.
JEP 261 may affect source code that is not compiled with the javac compiler using the -source, -target or -release options to select the use of legacy mode.
The stack traces generated for exceptions at run time have been extended to include, when present, the names and version strings of relevant modules. The detail strings of exceptions such as ClassCastException,IllegalAccessException, and IllegalAccessError have also been updated to include module information. Any code analysing, or filtering, based on the stack trace element's detail strings should be updated appropriately, to handle this.
In addition, this feature may affect code that assumes that the application class loader or the extension class loader is an instance of URLClassLoader, rather than of an internal class.
This feature may also affect code that attempts to set or read the bootclasspath using the -Xbootclasspath or the -Xbootclasspath/p options, or the removed JDK-specific system property sun.boot.class.path.
Changes due primarily to the introduction of the Java Platform Module System may affect code which
public modifier to an API element guarantees that the element will be everywhere accessible, or ClassLoader::getResource* and Class::getResource* methods to read JDK-internal resources, orjava.lang.reflect.AccessibleObject::setAccessible method to gain access to members of packages that are not exported by their defining modules, orExisting code that invokes ClassLoader::getSystemClassLoader and blindly casts the result to URLClassLoader, or does the same thing with the parent of that class loader, might not work correctly.
Existing custom class loaders that delegate directly to the bootstrap class loader might not work correctly; they should be updated to delegate to the extension class loader.
The five-parameter transform method declared in thejava.lang.instrument.ClassFileTransformer interface is now a default method.
Existing code that scans for META-INF/services resource files previously found in rt.jar and other internal artifacts which are not present in the corresponding system modules files might not work correctly.
The JDK-specific system property file.encoding can be set on the command line via the -D option, as before, but it will only work when it specifies a charset defined in the base module. Existing launch scripts that specify other charsets might not work correctly.
JDK-8011044 may affect source code that uses javac -source or -target options below 6/1.6 to compile.
JEP 221 may affect code that uses the Doclet API. It replaces the Doclet API with a simpler design that leverages newer alternative APIs with improved functionality, and updates the standard doclet to use it.
If you would like to provide feedback on JDK 9, but don't know yet where to start, please begin by subscribing to the adoption-discuss mailing list, and initiating a conversation on that mailing list about your particular item of feedback. Depending on the content, you may be asked to file an issue in in JBS, to provide further information or to continue the conversation on a specific OpenJDK Community mailing list more suitable for further discussion.
...
There may be other changes worth considering to add to this page. If you have suggestions for items to add to this list, please send an e-mail to the adoption-discuss mailing list.