Java 9 introduced several significant features, with the Java Platform Module System
(JPMS), codenamed Project Jigsaw, being the most impactful change.1
Here are the key features of Java 9:
Major Features
● Java Platform Module System (JPMS) / Project Jigsaw:2 This feature modularized the
JDK itself and introduced the concept of modules to the Java language.3
○ Goal: To make the Java platform more scalable, secure, and maintainable by
breaking the monolithic JRE into smaller, independent modules.4
○ Key Concept: A module is a named, self-describing collection of code and data.5 A
module explicitly declares its dependencies on other modules and which of its
packages it exports (makes public) to other modules.6 This provides strong
encapsulation and reliable configuration, replacing the brittle classpath
mechanism.7
○ Tool: The jlink tool allows you to create a smaller, custom runtime environment
containing only the modules your application needs.8
● JShell (Java REPL): A Read-Eval-Print Loop (REPL) interactive tool for quickly
prototyping, testing, and exploring Java code snippets and APIs without needing to
compile a full class and main method.9
● Private Interface Methods: Allows defining private and private static methods within
interfaces.10 This helps in reusing common code among the interface's default methods
without exposing the helper logic to implementing classes.11
API and Language Enhancements
● Factory Methods for Immutable Collections: New static factory methods were added
to the List, Set, and Map interfaces (e.g., [Link](), [Link](), [Link]()).12 These methods
provide a concise way to create unmodifiable (immutable) collections.13
● Stream API Improvements: Added several new methods to the Stream interface:14
○ takeWhile(Predicate) and dropWhile(Predicate) for conditionally taking or dropping
elements from a stream.15
○ ofNullable(T) to create a single-element stream if the element is non-null, or an
empty stream if null.16
○ An overloaded iterate() method that accepts a Predicate to specify a condition for
stopping the iteration.17
● Process API Updates: Enhanced the [Link] and introduced
[Link] to provide easier control and management of native
operating-system processes, including access to process ID (PID), arguments, start time,
and process tree traversal.18
● Try-With-Resources Improvement: The try-with-resources statement was enhanced to
allow using an effectively final variable that is already declared outside the try block,
reducing verbosity.19
● HTTP/2 Client: Introduced a new, modern HTTP client API under the [Link]
package to replace the legacy HttpURLConnection. 20This new client is designed to
support both HTTP/1.1 and HTTP/2 and works in both synchronous and asynchronous
modes (using CompletableFuture).21 (Note: This was an incubating feature in Java 9 and
was standardized in Java 11).22
● Enhanced @Deprecated Annotation: Added the attributes forRemoval() and since() to
provide better information to developers about the status and planned removal of
deprecated APIs.23
● Multi-Release JAR Files: Allows a single JAR file to contain different versions of class
files for different Java releases, making it easier for library developers to support multiple
Java versions from a single artifact.24
● Optional API Improvements: Added new methods like stream(), or(), and
ifPresentOrElse() to the Optional class for better functional programming and handling of
optional values.25