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

  • Context: Java 
  • Thread starter Thread starter QuantumQuest
  • Start date Start date
  • Tags Tags
    Java
Click For Summary
SUMMARY

Java 9 introduced significant features including the Java Module System, jshell (REPL), private methods in interfaces, and improvements to the try-with-resources statement. Additionally, it enhanced the java.util.Stream API and introduced an HTTP2 Client. Java 10 followed with a new time-based release cadence, local variable type inference, a Garbage Collector interface, and the introduction of an experimental Java-based JIT compiler. These updates are crucial for developers transitioning from Java 8 and those looking to leverage modern Java capabilities.

PREREQUISITES
  • Familiarity with Java programming language
  • Understanding of Java 8 features
  • Basic knowledge of Java Development Kit (JDK) and its components
  • Awareness of reactive programming concepts
NEXT STEPS
  • Explore Java Module System and its implementation in JDK 9
  • Learn about local variable type inference in Java 10 (JEP 286)
  • Investigate the new Garbage Collector interface and its benefits (JEP 304)
  • Research the experimental Graal JIT Compiler and its performance implications (JEP 317)
USEFUL FOR

Java developers, software engineers, and technical architects looking to upgrade their skills and utilize the latest features in Java 9 and 10 for improved application performance and maintainability.

Messages
928
Reaction score
481
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   Reactions: Greg Bernhardt
Technology news on Phys.org
About time for HTTP2 support!
 
  • Like
Likes   Reactions: QuantumQuest

Similar threads

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