Java is known for its timely and frequent updates via new releases of the JDK (Java Development Kit). Its elite software engineers go to great pains to ensure Java stays relevant for its users.
Oracle follows a six-month release schedule for standard Java. New versions arrive twice a year. Java 14 was made available on 17 March 2020. Java 15, the next version of Java SE (Standard Edition), is going to be quick on its heels.
We now discuss the major new features/enhancements confirmed to be part of JDK 15.
JEP 371: Hidden Classes
A hidden class is a type of class that cannot be directly used by the bytecode of other classes. It’s intended to only be used by frameworks that generate classes at runtime. And then a hidden class is used indirectly through reflection.
This feature will enable a standard API to define hidden classes that are not discoverable. It will have a limited lifecycle. The result? It will improve the efficiency of all languages on the JVM. Frameworks will now dynamically generate classes that will define hidden classes instead.
This is a useful feature. Because various languages built on the JVM rely on dynamic class generation. (As it provides efficiency and flexibility).
JEP 377: Z Garbage Collector (ZGC) (Production)
The Z Garbage Collector (ZGC) is a:
Garbage collector that was introduced in JDK 11.
Java’s top developers decided that a feature of this magnitude and complexity should be released carefully and gradually. That is why it was initially released as an experimental feature. This helped the top talent in Java to set user expectations. It also allowed them to get useful feedback from technology talent.
Since then, various improvements have been introduced with different releases, such as:
- Concurrent class unloading,
- Un-committing unused memory (JEP 351),
- Support for data-class sharing to improved NUMA awareness,
- Multi-threaded heap pre-touching.
- The maximum heap size has been increased from four terabytes to 16 terabytes and the minimum heap size decreased to 8MB.
- It now also supports all prominent platforms including Linux, Windows, and MacOS.
Testing now suggests that it is stable and error-free. ZGC’s platform support today is an important consideration. It validates Java’s top software engineers belief that this is the right time to make it a product feature. i.e. Remove the ‘experimental’ status.
JEP 378: Text Blocks (Standard)
Text Blocks were introduced as a preview feature in JDK 13. They was then re-visited and improved by adding two new escape sequences. In Java 14, they were featured as Second Preview.
These strings consist of code snippets written in non-Java languages. It is often hard to read an embedded HTML, XML, SQL, or JSON snippet in Java code. The main goal of text blocks is to enhance the readability of strings in Java programs.
Text blocks were well received in JDK 14 by Java coders. This gave the impetus to make text blocks a standard feature in Java 15.
JEP 379: Shenandoah (Production)
Shenandoah was first introduced in JDK 12 (JEP 189). (Initially as an experimental feature). It is now made a production feature in Java 15 and moves out of the experimental stage.
Shenandoah is a Low-Pause-Time Garbage Collector that reduces GC pause times. It does this by doing evacuation work simultaneously when running Java threads. Its pause times are independent of the Heap Size. This means a Java developer will experience the same consistent pause times. (Irrespective of the heap). The heap could range from 500 MB to even 500 GB without affecting pause time.
JEP 383: Foreign-Memory Access API (Second Incubator)
This feature will allow Java programs to access foreign memory outside of the Java heap. With safety and efficiency. The current Java API does not provide a proper solution for accessing foreign memory. This new feature will allow the API to maintain the safety of the JVM. It is currently going through an earlier incubator phase in JDK 14. Refinements are offered in JDK 15.
JEP 360: Sealed Classes
With JDK 15, a preview of sealed classes is released with interfaces. Sealed classes are classes that restrict the other classes or interfaces that may extend or implement them. They allow the creator of a class to control the code responsible for implementing it. This provides a more declarative way to limit the use of a superclass. (Compared to accessing modifiers).
JEP 375: Pattern Matching for instanceof (Second Preview)
The second preview of pattern matching for instanceof is now part of Java 15. The first preview was introduced in JDK 14. Pattern matching allows common logic to be implemented in a program. Even non-Java languages like C# have embraced pattern matching. Why not? Its safety and conciseness make it a must-have!
JEP 384: Records (Second Preview)
Records are included in JDK 15 as a second preview version. In JDK 14 they were introduced as an early preview. Records are classes that act as transparent carriers for immutable data. Records can be considered nominal tuples.
The goal of this preview is to help Java coders focus on modelling immutable data. (Instead of extensible behavior). With this, they can automatically implement data-driven methods like equals and assessors. This will also promote the preservation of longstanding Java principles like:
- Nominal typing and
- Migration compatibility
Frequent updates might seem difficult to catch up. But the opposite is true.
See Also: What’s New In Java Web Services?
Top software engineers already know how rapidly software development is changing. And with it, the changing needs of Java coders. Contributions from top talent in the Java community keep it relevant in a changing world.