Java 9 Migration Tips

Author: Shazin Sadakath


Java 9 was released this year and it is a much awaited release of Java with a lot of interesting and exciting features. But Upgrading is a concern for any
CTO or Infrastructure Team as it may break the existing functionality or create unforeseen issues.

But in a recent presentation, Bernard Traversat who is the Vice President of Development for the Java SE Platform at Oracle provided some tips on successful migration to Java 9. Bernard manages the development team responsible for the Java Language, JVM, Core libraries, Java UI toolkits, and Java deployment stack for Oracle JDK product. So who else is fit enough provide advise on Java 9 Migration than him.

Why Upgrading is required;

Why Upgrading is delayed;

Out of Programming Languages Java, Golang, Python, C# .NET, As per Bernard Only Java is Backward compatible and upgradable.
There are binary, source and runtime compability explicit managed in the Java platform. 

Most of the APIs (java.*, java.*) undergo millions of tests to ensure compatibility and have specifications managed under the JCP (Java Community Process).
In order to update a specification of an API, rigorous JCP process is required.

Migration

The following things remain the same from Java x to Java 9

Things to look out for when migrating from Java x to Java 9

Incompatibility issues you will face during or after migration;

No 1 issue will be a Third Party library you use in your older Java code is not compatible with Java 9 anymore. This is addressed as many open source projects and vendors are already changing their code base to Java 9 but in case one hasn't done already until they do your migration will have issues.

Apart from that following can also affect you and you must be aware;

1. JEP-260 Encapsulate most internal APIs - This means Internal APIs will no longer be accessible to developers. If your code uses an internal API then it needs to change.

2. JEP-223 New Version String Scheme - JDK 1.9.0_25 will turn into JDK 9.1.3. If your code contains any version string checking then it has to change.

3. JEP-220 Modular Runtime Images - No more rt.jar and JDK directory structure will change. If your code has any JDK directory checking then it needs to change.

4. Most sun.misc.* and sun.reflect.* are removed - If your code uses any of these packages then it needs to change. Ex:- you can no longer use sun.misc.Base64 class.

5. JEP-214 Remove Java 8 Deprecated GC Combinations - Following GC Combinations will now produce errors. You need to change your Java start up scripts if you use any.

DefNew + CMS       : -XX:-UseParNewGC -XX:+UseConcMarkSweepGC
ParNew + SerialOld : -XX:+UseParNewGC
ParNew + iCMS      : -Xincgc
ParNew + iCMS      : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC
DefNew + iCMS      : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC -XX:-UseParNewGC
CMS foreground     : -XX:+UseCMSCompactAtFullCollection
CMS foreground     : -XX:+CMSFullGCsBeforeCompaction
CMS foreground     : -XX:+UseCMSCollectionPassing

6. Launching JVM with Unrecognized VM Options will result in failure to start

7. java.awt.peer and java.awt.dnd.peer packages will be hidden - If your code uses these it needs to be changed to use supporting APIs

8. Calling Thread.stop(Throwable) method will throw an Exception - This was deprecated for a long time now. 

9. JEP-271 Unified GC Logging - Re-implemented GC Logging with the new JVM Logging framework JEP-158, If your Java start up scripts use any of the following they need to change.

-XX:+PrintGC will be changed to -Xlog:gc
-XX:+PrintGCDetails will be changed to -Xlog:gc*
-xloggc: will be changed to -Xlog:gc:

10. JEP-248 G1 is the new Garbage Collector - Serial GC is and will remain the default garbage collector for Windows 32 bit.

Conclusion

Migration to Java 9 is not as scary as it looks and will be easy with proper planning. Inorder to harness the full features it is advised to migrate 
in small increments so that issues arising can also be mitigated easily.

References

https://www.infoq.com/presentations/java-9-migrate



Tags: Java9 Migration
Views: 760
Register for more exciting articles

Comments

Please login or register to post a comment.


There are currently no comments.