Java 15: What You Should Know
Java 15 also does away with specific provisions and features to make its use much simpler than before. Let's explore some of those new features in this article.
Join the DZone community and get the full member experience.Join For Free
In September 2020, Oracle released a new short-term release for the Java Development Kit platform, a.k.a. Java 15. Of course, this caused quite a bit of excitement in the development world, mainly due to the many, many changes and advanced provisions it offered to developers.
Even though it was only a short-term release Java 15 managed to pack quite a punch; from hidden classes, text blocks, to the Z Garbage Collector, a foreign memory access API, and so much more.
Simply put, Java 15 offers as many as 15 significant improvements over the older version, including the designation of ZGC and Shenandoah GC as production instead of being continued as experimental.
Java 15 also does away with specific provisions and features to make its use much simpler than before. Nonetheless, it is worth noting that among all the changes it brings along, the most notable is unquestionably the preview addition of sealed classes. What makes it so great? Well, for starters, it empowers programmers to now explicitly outline subtypes while they are working on further advancements for pattern matching. Now, let’s discuss this and some other changes in detail.
- Sealed classes: Sealed classes help regulate interfaces and other courses that can either implement or extend them. The objective of this particular feature is to enable class or interface authors to manage the codes that are in charge of their implementation. It must be noted that sealed classes now involve the use of two new keywords, namely, sealed and permits
- New record class: Java 15 now also gets the new record class that enables developers to outline the same immutable objects much more concisely.
Some noteworthy changes include a new syntax for the class definition. It is primarily meant for records. The details about the fields within the record are provided in this header. Employing this header empowers the compiler to indicate internal fields.
- Hidden classes: Yet another essential new provision in Java 15 is hidden classes, which will prove beneficial for developers who work with either JVM languages or even dynamic byte code. But what purpose do classes serve? They enable creating non-discoverable sessions at runtime, which means they can neither be linked by other courses or even discovered through reflection since such courses are normally associated with a short lifecycle.
Hidden classes feature in Java 15 ensures it is efficient with not only loading but unloading as well. One critical point to note here is that the current Java iterations do facilitate the creation of anonymous classes quite like hidden classes. However, hidden classes are not dependent on Unsafe API, unlike anonymous classes.
Java 15 brings a whole lot to the table even though it remains a short-term release. There are the sealed classes, the pattern matching type checks, garbage collectors, and many other crucial changes.
Opinions expressed by DZone contributors are their own.