Java 15: New Features And Drawbacks Affecting the Developers?

Java 15: New Features And Drawbacks Affecting the Developers?

Java Development Kit 15 (JDK 15), Oracle's open-source reference implementation of Java Standard Edition, was made public on September 15, 2020. This release builds on several features from its predecessors and adds some new features as well.

As Java is the world's most popular programming language and application platform, its updates will impact many people in the tech industry. Across this article, we will explore some of the new Java 15 features and drawbacks.

What all is removed?

The Java 15 release removed the source code and build support for the following ports:

  • Solaris/SPARC
  • Solaris/x64
  • Linux/SPARC

A new version does not include the Nashorn JavaScript engine, APIs, and the JJS tool.

In the previous versions, the above-mentioned- ports, tools, APIs, and engines were deprecated with the expectation of removal in future releases.

What's new?

1. Sealed Class as a preview feature

In Java 15, the sole change to the language is incorporating sealed classes as a preview feature. Sealed classes are restricted from being extended or implemented by other classes.

Through this transition, necessary changes can be made by collecting user feedback, and if necessary, the feature could even be deleted. The --enable-preview flag must be used at both compile and runtime to enable preview features (the --release flag must be used at compile time).

The sealed Class’s syntax remains the existing way. To seal a class, use the sealed modifier - permits its declaration. After that, any Implements clauses and extends them.

2. Records

After debuting as an early preview in JDK 14, Records, which are described as classes that act as carriers for immutable data, are now available in JDK 15 as a second preview.

It intends to devise an object-oriented construct that denotes a simple aggregation of values. It can assist programmers in designing immutable data rather than extensible behavior, maintaining longstanding Java principles such as nominal typing and migration compatibility, and automatically implementing data-driven methods, such as equals and assessors. In a sense, records can be seen as nominal tuples.

3. Disable and Deprecate Biased Locking

The biased locking feature has always been available and enabled before Java 15.

When launching HotSpot with this proposal, biased locking will no longer be available unless -XX:+UseBiasedLocking is specified.

JEP will deprecate all options related to configuring and using biased locking. There will still be options to choose from, but users will see a warning of deprecation. Java applications may experience a performance regression if biased locking is disabled.

4. Hidden Classes

It isn't possible to access hidden classes directly from the bytecode of other classes; they are intended for frameworks that generate classes at runtime and use them obliquely through reflection. Typically, a hidden class is a member of an access control nest. It can unload independently of other classes.

With this proposal, all languages on the JVM would be more efficient with a standard API for creating hidden classes that cannot be discovered and have a finite lifespan.

5. Text Blocks

Text blocks are multi-line strings that can be formatted automatically by avoiding tedious escape sequences and offering the developer control over the format. Text block features that were previewed in JDK 14 and JDK 13 are no longer in preview and have been incorporated into the Java SE specification as part of the Java Language Specification.

In addition to making it easier to write Java programs by avoiding escape sequences in common circumstances, they are intended to simplify writing strings that span several source code lines and make Java programs that contain code written in non-java languages more readable.

6. Garbage Collectors

From a feature to a product, Z Garbage Collector (ZGC) has leaped JAVA 15. As part of JDK 11, released in September 2018, ZGC provides scalable, low-latency garbage collection.

Applications involving massive amounts of data, including machine learning, benefit from ZGC. Linux, Windows, and macOS are the platforms supporting ZGC.

Under Java 15, the Shenandoah low pause-time garbage collector would be a production feature, leaving behind the experimental stage. It was implemented in JDK 12 years ago.

7. Foreign Memory

The foreign memory access feature is already a Java 14 incubation feature. In Java 15, several new features will be added while maintaining the incubation status.

By implementing this, Java programs would be able to access memory outside the Java heap safely and efficiently. Native, persistent, and managed heaps should all foreign memory be operable through the API.

8. Pattern Matching

By pattern matching, program logic can be expressed more easily and concisely. With no new enhancements, Java 15 will continue its preview status of pattern matching.

It is intended to avoid a large amount of boilerplate code that typically comes with the instance of the operator.

9. DetagramSoket API DatagramSocket API is reimplemented by ousting the underlying implementations with simpler implementations that are easier to maintain and debug.

What More Could Have Been Added?

With few new features, Java 15 is not a significant release for developers. Either the features are tweaked versions of those of earlier releases, or they are removed or deprecated. Additionally, this version does not solve other long-standing Java problems.

The developers still find Java slow compared to C and C++ programming languages. They also find Java annoyingly lengthy and cumbersome. Java still lacks some named parameters and default parameters values, making many users fearful that they might never see them on the Java platform. Immutability is highly difficult to implement in Java.

Oracle must continue to add refreshing features that make Java programming even more user-friendly and cloud-capable to keep Java developers happy.

Conclusion

This release of Java 15 adds some great features and points to Java's future as a modern language where developers can utilize whatever paradigm they desire.

Organizations continue to use Java, but the constant flow of new features every six months can prove challenging. A Java development company can alleviate this situation by applying its expertise in the field.