Java 9 comes with a new feature very useful to library authors: multi-release JARs (JEP 238).
A multi-release JAR (MR JAR) may contain multiple variants of one and the same class, each targeting a specific Java version.
At runtime, the right variant of the class will be loaded automatically, depending on the Java version being used.
This allows library authors to take advantage of new Java versions early on, while keeping compatibility with older versions at the same time.
If for instance your library performs atomic compare-and-set operations on variables, you may currently be doing so using the sun.misc.Unsafe class.
As Unsafe has never been meant for usage outside the JDK itself,
Java 9 comes with a supported alternative for CAS logics in form of var handles.
By providing your library as an MR JAR, you can benefit from var handles when running on Java 9 while sticking to Unsafe when running on older platforms.
In the following we’ll discuss how to create an MR JAR using Apache Maven.
If you’ve ever watched the great show "Home Improvement", you’ll know that a fool with a tool is still a fool.
At the same time though, the right tool used in the right way can be very effective for solving complex issues.
In this post I’d like to introduce a tool called jQAssistant which I’ve found very useful for running all sorts of analyses of a project’s code base,
e.g. for preventing the leakage of internal types in the public API of a library.
This is planned to be the first post in a blog series on developer-centric tools we’ve come to value when working on the different libraries of the Hibernate family.