My Top Java 9 Features
My Top Java 9 Features
Now that Java 9 is out, check out one dev's favorite features that came with the update and how they have helped his work.
Join the DZone community and get the full member experience.Join For Free
Build vs Buy a Data Quality Solution: Which is Best for You? Gain insights on a hybrid approach. Download white paper now!
But now Java 9 is released, and this post takes a look at my top Java 9 features, which I will expand on in future posts.
A full list of Java 9 features can be found here, but the features I am most interested in are:
- Java Platform Modularity System (JPMS): Prior to Java 9, you could pretty much access any public class on your classpath. This made it difficult to truly encapsulate APIs. Java 9’s JPMS seeks to resolve this through a module descriptor – module-info.java – which defines module requirements and what it exports.
- JShell: REPL (Read-Eval-Print-Loop), or Shells, have been a common feature of other languages for a while, and Java has finally introduced a Java Shells. This provides a great environment for experimenting with APIs.
- HTTP/2 Client: This client provides HTTP 2.0 support in the Java platform and will replace the previous HttpURLConnection API. The key benefit of this is will result in improved performance over the HTTP 1.1 implementation.
- Streams API: There are some updates to the Streams API, including takeWhile and dropWhile, which take/drop elements while a condition remains true.
- Process API: The process API changes allow Java to manage OS processes without resorting to parsing the output of a call to System.exec. The simplest example is accessing the process Id, where we can now call:
int processId = ProcessHandle.current().pid();
- Private Methods in Interfaces: Java 8 introduced default and static methods in interfaces, allowing us to add behavior to interfaces. Private methods build on this by allowing default methods to call private methods implementing shared behavior.
You can download Java 9 here.
So, what are your favorite Java 9 features?
Published at DZone with permission of Martin Farrell , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.