02
Nov
2017

Unveiling Top 10 Java 9 Features List

Innovative trends in amalgamation with Information technology let businesses strive their unique positions in this competitive world. Talking about information technology, and leaving back programming languages and platforms is never wiser. Out of many of them, Java strives its unique popularity as an object oriented programming language with a simple object model across the world and also amongst technological communities.

Java-9-banner

Java 8 was released three years back or even more and now java developers are seeking for a new update in Java, version 9. The await of Java 9 is ended up on 21st September, 2017 and indeed the long wait came up with many positive optimization and enhancements. For businesses, Java developers and Companies providing Java Development services, Java 9 ends to be a huge plus as it comes up with more versatility and the capability to customize more features.

An Early list of Java 9 feature updates incorporates Process API, performance tweaks, new capabilities, modules updates and improvements in JEPs (JDK Enhancement Proposals) and JSRs (Java Specification Requests). Few of JEPs and JSRs are already been published.

Have a look on main Java 9 new features and improvements:

New Java Modular System

To develop and maintain libraries of large applications with complicated code and tangled dependencies is very difficult at times. But, in new update Jigsaw project came to rescue. In this, modules possess usual classes and new module declaration files and explicitly defines dependencies. Also, only those packages are considered encapsulated that are not mentioned in exports clause. Project Jigsaw is a major benefit for legacy java developers.

Code to declare module that exports some of its packages and requires others:

module eu.dreamix.java9.modules.accessories {
   requires eu.dreamix.java9.modules.powersupply;
   exports eu.dreamix.java9.modules.accessories.speakers;
}

Factory Methods

From now, no need to use Collections class to create Immutable Collection methods, as, Oracle Corp included some convenient and highly optimized factory methods in Java SE 9 to create Immutable List, Set, Map and Map.Entry objects. Also, methods to create empty or nonempty Collection objects are introduced. Examples of collection factory methods:

Set ints = Set.of(1, 2, 3);
List strings = List.of("first", "second");

Java 9 developers are relieved from picking up a specific collection implementation and even repetition of code leading to add ‘add’ calls to instantiate collection are also lessened.

Jshell – A New Command Line Tool

No more necessary to add and wrap code in the separate project to execute few Lines of Code, How? From the console, launch jshell and start executing the code which will immediately prompt the feedback. To be precise, Java Shell that is commonly known as jshell appends extensive native support to REPL (Read-Eval-Print-Loop). Demo of jshell snippet:

jdk-9\bin>jshell.exe
| Welcome to JShell -- Version 9
| For an introduction type: /help intro
jshell>2 + 2
| Expression value is: 4

Try With Resources Improvement

From Java 9, to execute try with resource statement, Java developers need not close all resources that are initialized in the try clause, alike previous versions. Final resources can directly be utilized in try clause, making the language more readable and efficient bypassing some more prolixity.

Private methods in Interfaces
Uptil, Java 8 only Default and Static methods were implemented in Interfaces, but with Java SE 9 even provide Private and Private Static (same as class private) methods in Interface. It is mainly introduced to dodge redundant code and also to re-use it.

Emended Javadoc

To generate Java code documents from Java source code in HTML format, Javadoc tool is used. Earlier developers practiced to surf on Google to search Javadoc pages, but new Java version – Javadoc comes up with a Search box in API documentation with a bonus of HTML 5 compliant.

Emended Javadoc

CompletableFuture API Improvements
Oracle Corp makeover CompletableFuture API in Java 9 to overcome few complaints raised in Java 8 – Delays and Timeouts methods and enhanced support to sub-classing and some of the utility methods. Example of the code:

Executor exe = CompletableFuture.delayedExecutor(80L, TimeUnit.SECONDS);

Diamond Operator for Anonymous Inner Class

Diamond Operator was introduced in Java SE 7, but in the further version, it was found that it has few limitations in using it with Anonymous Inner Class. The issue is fixed in the recent release of Java Version 9. Now, the variable can be specified without mentioning type parameter.

Predicate predicate = new Predicate<>() {
    @Override
    public boolean test(Integer input) {
        return input == 42;
    }
};

Reactive Streams

A public or subscribe framework used to implement Asynchronous, Scalable and Parallel applications efficiently is commonly called Reactive Streams. So far, Scala, Play, Akka, etc, like frameworks already are receiving adequate benefits of it, and now Java is also not lacking behind. Reactive Streams mainly resolve the endeavor of back-pressure.
Reactive Streams mainly is focused on core components mentioned as below:

  • java.util.concurrent.Flow
  • java.util.concurrent.Flow.Publisher
  • java.util.concurrent.Flow.Subscriber
  • java.util.concurrent.Flow.Processor

Java SE 9 update is chiefly targeted on Reactive Streams API.

Overdue Replacement of HttpURLConnection

New HTTP 2 Client API to support HTTP/2 protocol and WebSocket features are also offered in Java SE 9. Existing HTTP Client API has numerous issues like supports HTTP/1.1 protocol, does not support HTTP/2 protocol and WebSocket, works only in Blocking mode also followed many other in performance. In the new version 9, Old HttpURLConnection API is substituted with new HTTP client.

This API is being introduced under “java.net.http” package. It supports both HTTP/1.1 and HTTP/2 protocols, both Synchronous (Blocking Mode) and Asynchronous Modes (using WebSocket API).

Presumed to be, but Skipped Features

Just like Jigsaw, an update of standardized Lightweight JSON API was also on hype, but it is not included in the update. Mark Reinhold, chief architect of the Java platform, stated that it is an important extension but is cut due to some funding issues.

Developers expected Money and Currency API, but it looks like Oracle is not supporting it in new updated version – Java 9 also.

Java 9 Business Perks

For businesses differences and advancements in Java versions are not merely as important to them as the best software solutions that meet their prerequisites. Java SE 9 latest features results in business benefits like speedy development due to the modular structure with higher effectiveness, sets creation with a single line of code, rather than multiple, Microbenchmarks to analysis performance for every chunk of code, and HTTP 2.0 support to boost speed.

Road mapping and streamlining custom business solution and creating software based results in fewer issues and a win-win situation for all – Java Development Company, Client and Java Developers.