Why do I need this big data? Analysis of huge databases.8 July 2019
Seven wishes of a Polish chatbots user19 July 2019
Java is very popular, either because or despite the fact it was introduced 23 years ago. One of the main reasons why it is so popular is its independence from the platform. This means that Java can run on any operating system or computer.
Many of the largest web development applications and systems around the world are created using this language. Google, Amazon, Atlassian, Twitter, eBay and Netflix are just a few of the popular companies that use Java. With a six-month schedule for releasing new versions of Java, the developer community can expect new and better features for developers at an accelerated pace.
It’s been a while since Oracle introduced an accelerated six-month publishing term and it’s getting harder to keep up with every version and features they add to the table. On the other hand, this speed of release also means that Java introduces many new features that we can use. This means we have to keep an eye on what exciting features are being added. So let’s dive in and see what new features Java 12 has to offer.
New Java 12 features
Memory cleanup – Garbage Collector Shenandoah
This experimental feature aims to add a new garbage collecting algorithm called Shenandoah, created for applications that prefer speed of reaction and predictable short breaks. This feature introduces an algorithm that is powerful enough to run programs in the available memory, but also optimized enough to never interrupt a running program for more than a few milliseconds. The Shenandoah algorithm will help in shortening the garbage collection interval while performing evacuation work with Java threads running. It replaces concurrent CPU cycles and space for pause time improvements, so you have the same pause time as dependent on the size of the data.
The Switch expression
Switch Expressions aims to extend the switch instruction. Multi branching instruction, which provides an easy way to send the execution to different parts of the code inside, based on the value of the expression. This extension, currently in preview mode, allows us to use the switch as an instruction or expression to simplify encoding and prepare for the next upcoming update.
Existing improvements in garbage collector G1 module
Java 12 contains 2 updates to the default garbage collector – G1. The first one, helps to remove mixed collections of G1 if they may exceed the pause target. This is a change that aims to make the G1 collector better at achieving the specified delay goal. Currently G1 uses the analysis engine to select the amount of work to be done during the collection, and once the collection set has been defined and the collection has started, G1 must collect all live objects in all regions of the collection set, without stopping. This leads to the garbage collector exceeding the target pause time that this update is supposed to solve.
The second function of G1 also focuses on improving the efficiency of the garbage collector, especially when returning unused memory. The current version of G1 returns memory only from a Java heap or during a simultaneous cycle. This is where “Quickly return unused memory engaged with G1” appears, focusing on improving the memory cleaning module, automatically returning Java heap memory to the operating system when G1 is idle.
Other new Java features
Java Microbenchmarking Harness (JMH) provides a extensive framework for creating performance tests for Java applications. It helps people avoid many of the simple errors they make when trying to analyze the performance of an application: warm up, avoiding the elimination of code that will not occur in production, etc. Anyone interested in working on Java itself and modifying code can use it to compare performance, both before and after changes, but also to see how performance is compared to releases. A number of benchmark tests are available to allow for such testing and JMH design allows you to easily add new ones.
Introducing API for modeling nominal descriptions of key class artifacts and executive files. This API will be useful for tools that manipulate Java classes and methods.
One Aarch64 port, not two
OpenJDK has two ports for Arm 64 architecture, one provided by Oracle and the other by Red Hat. Since this was unnecessary and Oracle stopped supporting Arm for its JDK binary files, it was decided to use only Red Hat port, which is still maintained and developed.
Default CDS archives
Class data sharing (CDS) used to be a commercial feature in Oracle. With the recent move, completed in Java 11, to eliminate all functional differences between Oracle JDK and OpenJDK, CDS is now included in OpenJDK. To use CDS, an archive is required that has been generated for classes that are loaded at application startup.
Is it worth installing?
Thanks to constant updates we see more and more features being introduced into the language – but what do developers feel about this last change? Updating and implementing new language features in large systems and businesses is not always easy, not to mention creating compatibility with older code and local team tricks and workarounds.
And indeed, when we look at the latest versions of Java, we see that frequent releases do not mean that the latest version is the most popular. Although many developers can still use Java 8, the latest version of Java promises some significant improvements and is available for download from Oracle. Although Java 8 is considered old, its popularity is undeniable. In larger projects it may be a waste of time for migration to Java 12, and in addition, in relation to Java 11, there are not so many additions in the new version. Perhaps if you have big problems with memory garbage collecting interruptions and you use G1, it is worth to see if Java 12 helps you in any way.
First look at Java 13
The development repositories for Java 13 are now open and a new version should be available in September. In short, the new features will be:
- Java Intrinsics compiler for JDK APIs, which is supposed to enable method marking and describing relevant translations of candidates for internal functions (intrinsification)
- sending JDK Flight Recorder events for continuous monitoring, i.e. providing an API interface for continuous use of JFR data on disk, both in the case of ongoing applications and outside the process
It is no secret that Java has made our online life more comfortable. Writing code in Java has never been easier and creating programs that are safe and reliable.
JDK 12 provides a small number of new features and APIs, and the new switch expression is the most interesting for programmers. G1 users will undoubtedly appreciate the performance improvements. With the new version of the release we advise all users to test their applications in this version. Keeping up with the gradual changes will avoid surprises if you decide to move on to the next release of long-term support.