Java 9 is going to be released on 21th of 2017, according to the developers. Let's check what are the main features of this new version.
The primary goals of this Project are to:
- Make the Java SE Platform, and the JDK, more easily scalable
- down to small computing devices;
- Improve the security and maintainability of Java SE Platform Implementations in general, and the JDK in particular;
- Enable improved application performance; and
- Make it easier for developers to construct and maintain libraries
- and large applications, for both the Java SE and EE Platforms.
- To achieve these goals we propose to design and implement a standard module system for the Java SE Platform and to apply that system to the Platform itself, and to the JDK. The module system should be powerful enough to modularize the JDK and other large legacy code bases, yet still be approachable by all developers.
Learn more at OpenJDK.
JShell – The Interactive Java REPL
Java 9 will also include a new tool called "jshell", it means Java Shell and also known as REPL (Read Evaluate Print Loop). It can be used to execute and test any Java Constructs like class, interface, enum, object, statements etc. very easily without wrapping them in a separate method or project.
JShell can be launched directly from the console and you can start typing and executing Java code. One great example of jshell is to test regular expressions.
Improved Network Communication with HTTP/2.0 Support
Java 9 comes with a new way of performing HTTP based communication. It provides a long-awaited replacement of the old HttpURLConnection and supports both WebSockets and HTTP/2. The new API is located under the java.net.http package.
Enhanced Process API
Process API had a limited capability to control and manage operating system processes. Even for getting process PID, you would need to either use native code or a tricky workaround. Not to forget, you would need different implementation for each platform.
Stream API improvements
Java 9 brings significant improvements to the Stream API which packs a punch in creation of declarative pipelines of transformations on collections. Four new methods have been added to the java.util.Streaminterface – dropWhile, takeWhile, ofNullable. The iterate method gets a new overload, which helps in providing a Predicate on when to stop iterating.
The takeWhile method takes a predicate as an argument and returns a Stream of subset of the given Stream values until that Predicate returns false for first time. If first value does not satisfy that Predicate, it just returns an empty Stream.
Well, this is the most interesting stuff that Java 9 will include (as planned). We'll keep an eye on the most interesting news about Java 9.