One of the really exciting features added into Java 9 was the ability to have a multiple-jar release. This means that you can have a jar for Java 8, which also contains extra or different versions of classes which are used if a later version of Java is used. This feature was introduced in Java 9 in JEP-238. This makes it easier to try and support the most users (realistically Java 8) while allowing use of more modern features if a more modern Java version is available.
Adding multi-jar support needs a little bit of work in Java. I have found 2 approaches to doing it in Maven. Either you can recompile the Java11 code using AntRun (which is really nicely documented in this blog post) or you can have 2 Maven modules. Because we have a separate build module in JPedal for the shade plugin, we used the second approach in JPedal and AntRun in our JDeli build. There is also a really good article from Trisha Gee on creating multi-jars in IDEA.
At the moment, we are using this to add ONE additional file, module-info.java. This is another Java 9 feature (project Jigsaw) which allows users to make use of modularisation in their code. This allows us to lock the code down to the official API for JPedal/JDeli if you are using Java 9 or later. The module names are com.idrsolutions.jpedal and com.idrsolutions.jdeli for the module settings If you are using Java 8, nothing should change….
Going forward, this means while we support all Java releases 8 and above, we will be able to offer optimisations for the latest LTS (currently Java 11) and still provide complete support for an older version (currently Java 8). When we change the LTS, we will review this base release (which is likely to stay as Java 8 in the foreseeable future). Any changes will be announced well in advance on our blog as we did with the move to Java 8 and we will ask for customer feedback first. We will also be looking into any areas of the code where we can gain substantial performance or memory advantages from having an optimised Java 11 version of the code for Java 11 users.
At the moment, we regard the inclusion of module-info as experimental so would welcome any feedback and ideas on this or any areas where Java 11 specific enhancements would be welcomed. What are your thoughts?
IDRsolutions develop a Java PDF library, a PDF forms to HTML5 converter, a PDF to HTML5 or SVG converter and a Java Image Library that doubles as an ImageIO replacement. On the blog our team post about anything interesting they learn about.