Listen to the article
Your audio file will ready in a few seconds...
TL;DR: The newest version of the Java ecosystem, Java SE 17, has a lot to offer. From new features and changes in its release process, we’re covering Java 17, its long-term support, five of the key and main features, as well as referencing its need for licenses.
Everyone has been talking about Java 17 for months! Now’s the time to explore all it has to offer! We’re touching upon the improvements that come with Java 17 and its new release all the way up to the upcoming changes to Java 18. For that, we’ll cover grounds on the API that’s currently available, Java’s random number generator, the new pattern matching for switch, and its sealed class standard feature, as well as the foreign function and memory API, and its dynamic deserialization filters. To top it off, we’ll also briefly cover Java 18’s release and its difference with the Java 17 version.
If you speak Spanish, this blog is also accompanied by a recording of a 40-minute live webinar session you can also watch, if you’d like. Let’s get to the matter now.
Java’s six-month release system
First, it’s worth noting how it used to take three to four years for a new Java version to become available. There was a lot of testing going on back then on new features and functionalities before a release.
Back in 2018, under versions 8 and 9, Java changed its versioning system to a new time-based cadence with new releases every six months. The improvements since are very specific and users and developers are the ones giving all new feedback on those new functionalities.
Source: https://www.petefreitag.com/item/911.cfm
There are pros and cons to this new version release system for Java, of course.
The win-win situation is developers’ quick access to new functionalities to try out using Java. However, users can also get easily confused with new releases. Especially as those happen twice a calendar year. People can also be unsure at times of which functionalities are Oracle-endorsed, and which aren’t included in a given version.
What also changed for JDK8, JDK11 and JDK17 is licensing. Java went under a long-term support format for these versions that’s available via a license. Those guarantee enhanced security, performance, and stability. Versions 13, 14, and 15 do not have a guaranteed quality as the prior three named versions do, which means the most recent versions, 11 and 17, are the only ones offering long-term support.
A lot of related versions have come up in the process, as well. So the big question for developers right now is: What does each version hold and what sets each version apart from one another? It’s important to note all versions stem from one major source version called the OpenJDK, which is a recommended open source license.
Java 17’s specific characteristics
To begin, enhanced performance is a proven benchmark for Java’s 17 version. OptaPlanner’s use cases show a 8.66% faster performance on Java 17 when compared to Java 11, which also makes it 2.41% faster than its 16 version counterpart for G1GC. It’s also proven to be faster for certain mathematical calculations in creating algorithms, for example, and more.
Migration processes such as new releases of the kind we’re covering today also include deprecations. In software development, this usually means features that aren’t deemed useful or relevant for a new release, for example. Java 17 deprecates its applets.
The five more relevant JEPs
JEP is a Java-specific term related to Java Enhancement Proposals. The 17 version build includes 15+ different JEPs. The five most relevant, which we’re exploring next, relate to specific functions and actions, and can be deemed of most value from the development side.
The random number generator:
This JEP includes a fix to the random number generation in independent cases, disallowing two instances created with the same seed to generate an identical sequence of numbers. This means a faster performance on the user end with a more secure platform use. It’s also now more easily customizable through either of 12 PRNG algorithms.
Pattern matching for switch:
One of our biggest coding problems has to do with our ability to determine if an object corresponds to a specific class, or not. In practical terms, we used an instant soft for that. If-else sentences came into place to determine a group in accordance to different classes. We can now use switch-case sentences for this, eliminating the need for instant soft use altogether. The switch case now includes null value evaluation, as well. This feature depletes the need to write unnecessary code. We can also refine code for attributes or simple characteristics through this feature now.
Foreign function and memory API:
We need Java native functions to sync with functions in different languages other than Java. Native methods, specifically aimed at experts, are used to implement most other functionalities that are part of core libraries. And we do so through Java’s native interface (JNI). Java 17 also comes with a new functionality titled Panama Project, which makes it an easier and more transparent process to access other types of languages.
Context-specific deserialization filters:
This feature acts as a valuable filter for serialization and deserialization in Java. We can define characteristics such as size, file content, and even keep a different file from being loaded if it doesn’t meet our desired criteria.
Seal classes:
There are instances where a given class must not necessarily inherit a quality from its mother class or it must only do so under a given set of characteristics or behaviors. Otherwise, our design might be slightly off in some ways. Java’s new release allows us to define which characteristics can be inherited from the mother class to any given subclass. This brings design closer to our business rules. Being able to set these restrictions allows for protection of an internal state of class or a class hierarchy along with added protection from foreign code compromises to our thread safety. Doing so also adds security to Liskov substitution principle (LSP) violations.
All of the above updates ensure improvement for the long-term with upcoming version releases.
Java 18 updates: The difference
As for Java 18, there is only a six month time difference between it and Java 17, which means the updates aren’t as trascendental or numerous as we’ve been able to see with other releases.
However, Java 18 has improvements in terms of its foreign function memory. We just mentioned this above in terms of the Panama project. But add to it that there’s now superior performance regarding the vector API, as well, which is more aimed at CPU architectures for scalable vector extensions.
The version also continues to perfect issues related to pattern matching for switch while it also continues improvements and updates to libraries. Amongst these stands a simple web server. It only serves static files for now, such as HTML or images, but it can prove useful for prototyping, testing, and ad-hoc coding. It also allows simple testing, nothing too big in size.
Though not many people go through the updates, we’ve had a great experience
In spite of all of the above, we must acknowledge that the most popular version of Java up to last year was Java 8, however. There are a number of diverse reasons for that, including user hesitation to update as new releases become available.
However, we’d like to leave you with the assurance on our part that we’ve made the best of the enhanced performance every release has to offer and have had great successes with the new versions in our daily work up to this point.
Care to learn more about Java?
[CTA] Check out our upcoming webinar.
Was this article insightful? Then don’t forget to look at other blog posts and follow us on LinkedIn, Twitter, Facebook, and Instagram.