Java What are the key features of Java 9 and 10 that developers should know?

  • Thread starter Thread starter QuantumQuest
  • Start date Start date
  • Tags Tags
    Java
Click For Summary
Java 9 introduced significant features including the Java Module System for improved modularity, jshell for interactive testing, private methods in interfaces, and enhancements to the try-with-resources statement. It also added Reactive Streams for asynchronous programming, HTTP2 client support, and improvements to the java.util.Stream API. Java 10 established a six-month release cadence, introduced local variable type inference, and enhanced garbage collection with a new interface and parallel full GC for G1. Additionally, it allowed heap allocation on alternative memory devices and introduced an experimental Java-based JIT compiler. These updates reflect ongoing enhancements in Java aimed at improving developer productivity and application performance.
Messages
927
Reaction score
484
It is about five months since Java 9 was released (JDK 9.0.1 October 17, 2017) and while developers and other users of Java try to keep up to pace with its new features - while others are just adopting Java 8, Java 10 is out! So, I thought that it would be useful for anyone developing / using / interested in Java language and is not aware of those latest releases to briefly review some important Java 9 features and refer to some interesting new features of Java 10.

Java 9 brought a lot of new features and improvements in already existent features. Some of the important ones are

- Java 9 Module System. That was a really big change. As part of the Jigsaw Project Oracle introduced
Modular JDK, Java Platform Module System, Modular Java Source Code, Modular Run-time Images, Encapsulation of Java Internal APIs. The Java 9 Module System was introduced to mitigate the shortcomings of the monolithic way JAR files of Java applications were developed in the past.

- jshell (a.k.a REPL(Read Evaluate Print Loop)) . It is used for easy testing and execution of various Java constructs like class, object, interface etc.

- Private methods in interfaces. From Java 9 on we can utilize private and private static methods in interfaces.

- try-with-resources statement improvement. Although this construct was introduced in Java SE7 there are improvements in Java 9 version regarding verbosity and readability.

- Reactive Streams. As reactive programming has become popular (Scala, Play etc.) Oracle introduced Reactive Streams API. It works in a publish / subscribe fashion and is used to implement Asynchronous, Scalable and Parallel applications in Java.

- Diamond Operator for Anonymous inner classes. The Diamond Operator was introduced in Java SE 7 and it was extended in Java 9 to cover Anonymous inner classes as well.

- java.util.Stream improvement. Three new methods added namely takeWhile(), dropWhile() and ofNullable(). Also the iterate() method was improved in order to solve the problem of non-stopping iteration.

- HTTP2 Client. Java 9 introduced support for HTTP2 protocol and WebSocket.

- There are other various features like Compact Strings, GC improvements, HTML5 Doc etc.

For what's new in Oracle JDK 9 in detail see Oracle's official page

Now, for Java 10 some important features are

- Time-based release versioning . With the introduction of Java 10 a new release cadence has been adopted: six months. Now, this feature although highly debatable among Java developers regarding its usefulness it is what will be followed. There will be LTS (Long Term Support) versions every three years.
For more see JEP 322

- Local Variable Type Inference. As a web developer for some long time I found this feature particularly interesting as it reminds me of JavaScript even in a very limited way. So, Java 10 gives the power of declaring a local variable without specifying its type which is inferred from context. The "local" word was put in italics because Java allows only that. This doesn't make it a dynamically typed language in any way:
The type inferred from context the first time sticks. For more see JEP 286

- Garbage Collector (GC) Interface and Parallel Full GC for G1. The first means an easier way to exclude a GC from a JDK build or adding a new GC without affecting the code base. The second improves overall performance in concurrent collections by parallelizing the full GC with G1 Garbage Collector which was introduced in Java 9. For more see JEP 304 and JEP 307

- Heap Allocation on Alternative Memory Devices. This gives the ability to the VM to allocate object heap on a memory device specified by the user. For more see JEP 316

- Experimental Java-Based JIT Compiler. In Java 9 Graal JIT Compiler was added. Now, in Java 10 it can be used as an experimental compiler on Linux / x64 platform. For more see JEP 317

- Thread-Local Handshakes. Introduces a way to execute a callback on threads without performing a global VM safepoint. Make it both possible and cheap to stop individual threads and not just all threads or none. For more see JEP 312

These are just some interesting new features / improvements in Java 10. For more about it in detail see Oracle's official page.

Sources:

Oracle Corporation Java Documentation
OpenJDK
 
  • Like
Likes Greg Bernhardt
Technology news on Phys.org
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 49 ·
2
Replies
49
Views
11K
Replies
29
Views
5K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 0 ·
Replies
0
Views
2K
Replies
1
Views
2K
Replies
3
Views
4K
  • · Replies 19 ·
Replies
19
Views
5K
  • · Replies 1 ·
Replies
1
Views
12K
  • · Replies 5 ·
Replies
5
Views
4K