Exploring Java 9 & 10 Features: JDK 9.0.1 & Beyond

  • Java
  • Thread starter QuantumQuest
  • Start date
  • Tags
    Java
In summary, Java 9 and 10 bring a multitude of new features and improvements to the Java platform. Some of the most notable changes include the modularization of the JDK, enhanced security, and improved performance. Developers can now take advantage of new language enhancements, such as private methods in interfaces and the var keyword, as well as new APIs for creating reactive streams and handling HTTP/2 connections. Java 9 also introduces the jshell tool, allowing for easier experimentation and testing of code. Looking towards the future, Java 10 brings even more enhancements, such as local variable type inference and application class-data sharing. These updates make Java a more versatile and efficient language for building robust and scalable applications.
  • #1
QuantumQuest
Science Advisor
Insights Author
Gold Member
927
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
  • #2
About time for HTTP2 support!
 
  • Like
Likes QuantumQuest

What are the new features in JDK 9?

JDK 9 introduces a variety of new features, including the Java Platform Module System (JPMS), the jshell tool for interactive Java programming, and enhanced stream APIs.

What is the significance of the Java Platform Module System (JPMS)?

The JPMS is a major change in JDK 9 that allows for more modular and scalable development. It helps to improve security, performance, and maintainability of Java applications.

How has the jshell tool improved the Java development process?

The jshell tool, also known as the Java REPL (Read-Eval-Print Loop), allows for quick and interactive experimentation with Java code. This can help with learning and debugging, as well as speeding up the development process.

What are some of the new enhancements to streams in JDK 9?

JDK 9 introduces new methods to the Stream interface, including takeWhile, dropWhile, and iterate. These methods make it easier to perform conditional operations on streams.

What new features can we expect in JDK 10 and beyond?

JDK 10 and future versions plan to focus on improving the overall performance and stability of Java, as well as introducing new features such as local variable type inference and improved garbage collection.

Similar threads

  • Programming and Computer Science
2
Replies
49
Views
10K
  • Programming and Computer Science
Replies
29
Views
3K
  • Programming and Computer Science
Replies
3
Views
5K
Replies
1
Views
1K
  • Astronomy and Astrophysics
Replies
19
Views
4K
Replies
4
Views
3K
  • Beyond the Standard Models
Replies
2
Views
3K
Replies
4
Views
30K
  • Beyond the Standard Models
Replies
2
Views
2K
Back
Top