Java 9 was released on September 22, 2017, bringing with it many new features. The main change is the modular system that has been implemented. Next we will detail the new features of Java 9.
Java 9 New Features
- Modular system : A module is a container of packages. One of the biggest changes in Java 9 is the introduction of a modular system (Jigsaw project).
- REPL (JShell) : Interactive programming environment.
- HTTP 2 Client : The HTTP/2 standard is the latest version of the HTTP protocol. The new HTTPClient API supports WebSocket and HTTP2 streaming and server push features.
- Improved Javadoc : Javadoc now supports searching in API documentation. In addition, Javadoc's output now conforms to the HTML5 compliant standard.
- Multi-version compatible JAR packages : The multi-version compatible JAR feature allows you to create a class version that you choose to use when running the library program only in a specific version of the Java environment.
- Collection factory methods : In the List, Set, and Map interfaces, new static factory methods can create immutable instances of these collections.
- Private interface method : Use the private private method in the interface. We can use the private access modifier to write private methods in the interface.
- Process APIs : Improved APIs to control and manage operating system processes. The introduction of java.lang.ProcessHandle and its nested interface Info to allow developers to escape oftentimes has to use local code because of the PID of a local process.
- Improved Stream API : Improved Stream API allows filtering of incoming streams of object serialized data for improved security and robustness
- Improved try-with-resources : If you already have a resource that is final or equivalent to a final variable, you can use that variable in a try-with-resources statement without having to declare a new variable in a try-with-resources statement .
- Improved deprecated annotation @Deprecated : The annotation @Deprecated can mark the Java API state and can indicate that the marked API will be removed or destroyed.
- Diamond Operator : An anonymous class can use the Diamond Operator.
- Improved Optional class : java.util.Optional adds a lot of new and useful methods, Optional can be directly converted to stream.
- Multi-resolution image API : Define multi-resolution image API, developers can easily manipulate and display different resolution images.
- Improved CompletableFuture API : The asynchronous mechanism of the CompletableFuture class can perform operations when the ProcessHandle.onExit method exits.
- Lightweight JSON API : Built a lightweight JSON API
- Reactive Streams API : Java 9 introduced a new responsive streaming API to support responsive programming in Java 9.
More new features can be found on the official website: What's New in JDK 9
JDK 9 download address: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-doc-downloads-3850606.html
In the case of the Java 9 article, we all use the jdk 1.9 environment. You can use the following command to view the current version of jdk:
$ java -version java version "9-ea" Java(TM) SE Runtime Environment (build 9-ea+163) Java HotSpot(TM) 64-Bit Server VM (build 9-ea+163, mixed mode)Next we will detail the new features of Java 9 for everyone:
| No. | characteristic |
|---|---|
| 1 | Modular system |
| 2 | REPL (JShell) |
| 3 | Improved Javadoc |
| 4 | Multi-version compatible JAR package |
| 5 | Collection factory method |
| 6 | Private interface method |
| 7 | Process API |
| 8 | Stream API |
| 9 | try-with-resources |
| 10 | @Deprecated |
| 11 | Internal class of Diamond Operators |
| 12 | Optional class |
| 13 | Multi-resolution image API |
| 14 | CompletableFuture API |
Comments
Post a Comment