What You Can Expect From Java 9 (Coming in July)

March 20, 2017

What's the difference between Java 8 and Java 9, which is coming out in July.

Are you ready for Java 9? Well, it is just about here! The general release of Java 9 is scheduled for July 7, 2017.  

As a Java developer, it is always important to get a good understanding of what new features are being added, what is changing, what is no longer supported (also called deprecated).  To help get ready for this transition, I wanted to share my understanding of what we can expect in the coming months from Oracle.

According to the OpenJDK website,

“We achieved the Feature Extension Complete milestone in December 2016. The overall feature set is now frozen.”

In Java 8, we needed to learn some new coding techniques, such as lambda expressions, collections such as streams and improved type inference, just to name a few.  It changed the way we code in some cases. Java 9 seems to be more centered around the way Java is engineered.

After reading the documentation and blogs on the upcoming release, some of the more important changes seem to be around the idea of making Java a modular system.  It is supposed to help with a term that was new to me, “JAR Hell”.  Seems a little harsh, but I understand the difficulties and problems that can arise with jar files (Java ARchive files).

As developers, it might be an adjustment to get used to only compiling and specifying the packages and libraries required for our program.  But in the long run, the benefit definitely outweighs the learning curve.

There is one new feature that promises to be fun, that is the introduction of an interactive Java Shell, called JShell! If you have done any coding in Scala, SML, or similar functional languages, you might have used a similar tool.  The API tool provides a way to interactively evaluate declarations, statements and expressions of the Java programming language within the JShell state without requiring a complete program to wrap around it without jar files, just instant results.

In the past there have been problems with using the classpath and, if you take a look at the package structure, the first thought that comes to my mind is spaghetti! Here is a snapshot of part of the image:

The new structure is driven by a long time of wanting a more structured library organization and with the influx of IoT, it is becoming increasingly important to address scalability.  Which is ironic, since in the past, that always meant that your application had to scale up to handle larger programs and larger amounts of data.  

Now, we need to scale down and make our programs extremely small and lightweight for the smaller IoT devices!

Now that I’ve introduced some of the big picture for Java 9, here are some of the highlights expected with this new release:

  • Resolve problems with classpath and a monolithic jdk that does not fit on smaller portable devices, the biggest change is the introduction of Project Jigsaw (Java Platform Modularization).

  • The Java platform modular system is aimed at reliable configuration and strong encapsulation, the goals are:

    • Make the Java SE Platform, and the JDK, more easily scalable down to small computing devices.

    • Improve the security and maintainability of Java SE Platform Implementations in general, and the JDK in particular.

    • Enable improved application performance.

    • Make it easier for developers to construct and maintain libraries and large applications, for both the Java SE and EE Platforms.

    • Make Java SE more flexible and scalable.

  • In this brave new world, we finally have a REPL session for Java called JShell - the JShell API and tool will provide a way to interactively evaluate declarations, statements, and expressions of the Java programming language within the JShell state.  If you have ever worked with Scala or other functional programming languages, you have probably used a REPL session (Read, Evaluate, Print, Loop).  This provides an interactive programming tool.  It provides immediate feedback which is great when programming.

  • Change the binary structure of the JRE and JDK:

  • Java 9 will have full support for HTTP 2.0 and feature a new HTTP client for Java that will replace HttpURLConnection, and also implement HTTP 2.0 and websockets.

  • A common command-line options for all logging

  • An improved way to control the JVM compilers. It enables runtime manageable, method dependent compiler flags

  • Divide the code cache into distinct segments, each of which contains compiled code of a particular type, in order to improve performance and enable future extensions

    • Instead of having a single code heap, the code cache is segmented into distinct code heaps, each of which contains compiled code of a particular type. Such a design enables us to separate code with different properties. There are three different top-level types of compiled code:

  • JVM internal (non-method) code

  • Profiled-code

  • Non-profiled code

For a full list of all the new features and changes, check out this page from Oracle. Stay tuned for the next installation of the Java 9 for Java 8 Developers where we will go into detail on how to download the early version of Java 9 and run the new REPL tool.

Peggy Fisher is a staff author for LinkedIn Learning in the developer segment, covering topics like fundamentals for C++Java and ArduinoSee all of Fisher's classes here