New Features In Java 9
In September 2017, Oracle released Java SE 9 with over 150 new features. The latest version
of the widely used programming language comes with several new features and APIs to accelerate
development of applications for both large and small devices. At the same time, the features
provided by Java 9 help programmers to improve application's performance, security, and maintainability.
Hence, it becomes essential for programmers to understand some of the key features provided
by Java 9.
What Programmers Need to Know about Java 9
multiple modules. Each modular JAR file contains a module descriptor. The developers can define
interdependency of various modules through requires statements. The modularity makes it easier
for programmers to run JVM modules smoothly on small devices that lack additional memory. At
the same time, they can also run only the APIs and JVM modules required by the application.
Java 9 improves code compilation process significantly through ahead-of-time (AOT) compilation.
The programmers can leverage AOT compilation compile Java classes into native code even before
the virtual machine launches them. AOT compilation improves the performance of both large and
small applications by overcoming major shortcomings of just-in-time (JIT) compilation. Unlike
JIT compilation, AOT compilation ensures that no Java method remains uncompiled.
Java 9 comes with a new real-eval-print-loop (REPL) command line tool - Shell. Shell
is designed with features to evaluate declarative statements and expressions interactively.
A programmer can use Shell to assess the quality of Java code before compilation. He can simply
enter a piece of code and collect feedback. Shell even has the capability to complete tabs
and add required terminal semicolons automatically. The new REPL tool makes Java compete with
widely used programming languages like Python and Scala.
The improved Javadoc documentation tool provided by Java 9 has the capability to generate
HTML5 markup. Also, latest version of the programming language supports several new characters,
blocks, and scripts as part of Unicode 8.0 encoding standard. At the same time, Java 9 comes
analysis in various IDEs and frameworks directly with the parser API for Nashorn's ECMAScript
syntax tree provided by JDK.
Improved Stream API
While writing Java code, programmers use strings to express calculations. Java 8 accelerated
stream processing by providing the Streams API. Java 9 comes with an improved version of the
Streams API that enables developers to take and drop items from Stream based on specific conditions
by adding methods. Also, the improved Streams API is designed with features to create a stream
for nullable value and iterate over Stream elements.
Multi-Resolution Image API
Java 9 introduces a new interface - MultiResolutionImage - to create a single multi-resolution
image by encapsulating multiple images with varying resolutions. The developers can further
use the Multi-Resolution Image API provided by Java 9 to get various variants of a single image.
Also, they can use the API to select a particular image based on the required resolution. Hence,
the Java programmers can now use a single API to create a unified multi-resolution image and
get resolution-specific image variants.
http://2 client API
Java 9 completely changed the way applications make HTTP calls. It replaces the HttpURLConnection
API with a new HTTP client API. The HTTP client API supports both http://2 and WebSockets.
However, the API is currently not a part of Java SE. It is implemented as an incubator module
which lives under the jdk.incubtor namespace. But the HTTP client API supports the latest communication
standards, while overcoming the shortcomings of the HttpURLConnection API.