Java 9 is the latest JDK release which is planned to be released in 2017. The release consists of new enhanced language concepts, new APIs, command line tooling enhancements and the mostly anticipated modularity support via Project Jigsaw.

Building an API is not an overnight task. It consumes many hours and effort. Starting from 2014 the developers are on the move and working hard to present the ultimate version with best features. The first scheduled date for completing the features was June 2016. In 2017, there are still several milestones to be achieved with extensive testing and bug fixes. The current planned release date is postponed to 27th July 2017. According to the chief architect of Oracle’s Java Platform Group, Mark Reinhold, the main time consumer (and also the most important feature) of the new release is Project Jigsaw, the standard module system for the java SE platform.

Java Module System – Project Jigsaw

In the software world, a module is a unique standalone piece of code which is strictly independent with a set of tightly coupled functionalities. No module is useful when isolated, hence interfaces are introduced to maintain the flawless communication among modules.

Project Jigsaw is the most likely candidate in forming module system. The Project Jigsaw will make Java SE flexible and scalable, improve security and maintainability, easy construction, maintenance, deployment and upgrade of large scale applications. The main goal is divide JDK into smaller modules while removing huge rts.jar and tools.jar from the JDK system thereby restructuring the JRE images introducing the module system.

Java 9 module consists of 3 main parts:

  1. Unique name – An identification for each module. JDK 9 consists of 95 Modules.
  2. Export clause – Set of packages to export from the declaring module to outside modules
  3. Requires clause – Set of modules to import from outside to the current module, which current module depends on

Code for module resides in a concept called ‘Module Descriptor’. The module description is expressed in a source file called ‘module-info.java’ and it is a plain java file. Module Descriptor should be placed in the root folder of the module.

  • Each Module can have any number of Packages and Types
  • Anyone can create their own modules
  • One module can depend on any number of modules
  • One Module cannot have multiple sub-module code and descriptions

Features of Java 9 Modular System

Scalable Java SE Platform with Modularized JDK

The former JDKs are complex, heavily interconnected with many undesirable dependencies with several APIs and different implementations. Huge scale JDK causes small applications and devices performance degrade as well as affect smooth testing and maintenance.  Now with modularized JDK, it can be easily integrated into small devices and efficiently use in the cloud platform.

Simplified structure and easy configuration of JAR files

The problem with configuring JAR files is the use of one and only classpath to access a bunch of JARs without proper categorization or modeling. It’s hard to find any distinction among configured JARs which causing ‘JAR Hell’ situation. JAR Hell contains many different issues like unexpressed dependencies. Transitive dependencies, shadowing, version conflicts and complex class loading.

Enhanced Encapsulation

Current Java has the most open ‘public’ access modifier allowing every public type to be accessed by every other type.  In contrast, Java 9 hide implementation inside a module and only expose public APIs. Also, it allows a component to declare which of its APIs are accessible by other components, and which are not. If a class is not in an exported package, no one outside of your module can access it – even if it is public.

Java Language Modifications

Factory Methods for immutable Collections

Prior to java 9 creating even a small immutable collection involved many steps and lines. As the Collections are frequent in the day today coding, this is a real pain for developers. Java 9 has addressed this concern by introducing Factory Methods for Collections.

Interface Method – Private

Java 8 introduces a new interface method – default. But it caused code reusing and threading problems. With Java 9 private method, no need to write duplicate code and enable exposing only intended methods to clients

Try-With-Resources Improvements

Java 7 introduced the try-with-resource new construct to manage resources automatically. Java 9 has provides some improvements for the statement to address verbosity and resource management concerns.

Diamond Operator for Anonymous Classes

Java 7 found the Diamond Operator to avoid redundant code and verbosity. Java 8 was to find the limitations in the use of diamond operator with anonymous classes.

Java 9 Flow API for Reactive Programming

Technology is evolving at great speed, so is software development technologies and concepts. Java should also adjust itself to cater robust and flexible technology requirements.   The introduction of reactive programming is a good initiative. Reactive programming will enhance software systems with flexibility, loose-coupling and scalability.