Java 9 Final Release: The Module System, JShell REPL, and G1 Garbage Collector

A major step forward for Java. We explore Project Jigsaw modularity, JShell interactive console, and the default G1 collector.

VP
SHIVAM ITCS
·6 September 2017·10 min read·1 views

Technical Overview & Strategic Context

After multiple delays, Oracle released the final version of Java 9 in September 2017. The core update is the modularization of the JDK through Project Jigsaw, which improves security and reduces runtime sizes. Beyond modularity, Java 9 introduced JShell (an interactive REPL console) and made the G1 (Garbage First) collector the default garbage collector, optimizing performance for large-scale enterprise applications.

Architectural Principle: Use the jlink tool to bundle modular Java applications with minimal runtimes. Leverage the G1 garbage collector to improve heap performance.

Core Concepts & Architectural Blueprint

Project Jigsaw structures the JDK into distinct modules, allowing developers to create custom JRE packages that bundle only the modules required by the application. JShell provides an interactive REPL console for testing Java expressions, while making the G1 collector the default garbage collector optimizes GC performance for enterprise systems.

Performance & Capability Comparison

Java FeatureJava 8 StandardJava 9 StandardOperational Benefit
Runtime StructureMonolithic JDK packagesModular JDK modules (Project Jigsaw)Reduces runtime size and footprint
Garbage CollectorParallel GC default settingG1 (Garbage First) collector defaultReduces GC pause times on large heaps
Interactive ConsoleNo native interactive shellJShell REPL consoleAllows rapid testing of Java expressions

Implementation & Code Pattern

To write a modular Java application and compile it under Java 9 guidelines, follow these steps:

  • Create a module-info.java file in the source directory.
  • Specify dependencies using requires statements in the module configuration.
  • Compile the modular Java application using the javac tool.
  • Generate custom, lightweight runtime images using the jlink tool.
javacode
// Compiling and running modular Java 9 applications
// Directory structure:
// src/in.shivamitcs.analytics/module-info.java
// src/in.shivamitcs.analytics/in/shivamitcs/analytics/Engine.java

// module-info.java
module in.shivamitcs.analytics {
    exports in.shivamitcs.analytics;
}

// Engine.java
package in.shivamitcs.analytics;

public class Engine {
    public static void main(String[] args) {
        System.out.println("Java 9 Modular Engine: Active");
    }
}

// Compilation commands:
// javac -d mods/in.shivamitcs.analytics src/in.shivamitcs.analytics/module-info.java src/in.shivamitcs.analytics/in/shivamitcs/analytics/Engine.java
// java --module-path mods -m in.shivamitcs.analytics/in.shivamitcs.analytics.Engine

Operational Governance & Future Outlook

The final release of Java 9 introduced key improvements to modularity and performance. Project Jigsaw modularization and the default G1 garbage collector help ensure enterprise Java systems remain scalable.

VP
Vijay Paliwal
Founder, SHIVAM ITCS · 18+ years enterprise & AI engineering
MCA · Ex-HiveGPT USA · Ex-Social27 Seattle
Java 9 Final Release: The Module System, JShell REPL, and G1 Garbage Collector | SHIVAM ITCS Blog | SHIVAM ITCS