Qcon "How you deploy Java, how you get access to updates and patches is all changing. Although Oracle has told people about this, they haven't been shouting about it," Azul Systems deputy CTO Simon Ritter told attendees at QCon, a developer conference under way in London.
Java used to evolve with comfortable though frustrating slowness, with major releases intended to come every two or three years and usually taking longer. Now the reverse is true, with updates every six months. JDK (Java Development Kit) 9 became generally available in September 2017 and will be obsolete by the end of March 2018. This means there will be no public updates. Developers either have to migrate applications to JDK 10, which will have an equally short life, or stick with JDK 8.
"Being on the release train is a big commitment," noted Java developer Stephen Colebourne. "Given the number of external tools/dependencies to consider ... it's a bold choice to use Java 9 or 10."
Some relief comes with JDK 11, which Oracle has designated an LTS (Long Term Servicing) release. This should arrive in September 2018 and will be supported until 2026.
However, Oracle has lost enthusiasm for the idea of keeping every desktop and server up to date with the latest version of the JRE (Java Runtime Environment).
"Oracle does not plan to migrate desktops from Java 8 to later versions via the auto update feature," the official statement, er, stated. "Individuals who require Java SE for non-corporate desktop use will continue to receive updates through at least December 2020. Instead of relying on a pre-installed standalone JRE, we encourage application developers to deliver JREs with their applications."
In addition, Oracle is limiting its official binaries to 64-bit Linux, SPARC, Windows and Mac. If you want runtimes for other operating systems, you will need to compile your own or find them elsewhere. The code is easy to find thanks to the official OpenJDK site. Linux distributions also typically package Java runtimes for their users.
Major Java changes
The idea of shipping a JRE with your application is now more efficient thanks to modularisation (Project Jigsaw) in JDK 9 and higher. A new tool called Jlink lets you specify which modules to include in a custom runtime. There is a core module called java.base which is always needed.
Java developers need to become familiar with the modulepath, by which modules are discovered at runtime, rather than the old classpath, though the classpath is still supported for compatibility.
In addition, certain Java features are deprecated and will actually be removed. These include:
- The Java plugin and Web Start technology. No more Java applets – though in practise these are already problematic thanks to removal of support in browsers such as Chrome, Firefox and Edge.
- JavaFX – originally Sun's answer to Flash and Silverlight, this will be gone in JDK 11.
- SOAP (java.xml.ws) is deprecated and may be removed in JDK 11. This may be a problem; quite a few hands went up when Ritter asked at QCon who is using SOAP.
- CORBA, a system for distributed objects, is suffering a similar fate, though few now use it.
JShell, an interactive shell for Java in JDK 9
Of course there is also plenty of new stuff. JDK 9 was a big release and introduced features including:
- JShell: a REPL (Read-Evaluate-Print-Loop) tool that enables interactive Java, useful for teaching and prototyping
- Improved Streams API
- Experimental AOT (Ahead of Time) compiler
Along with hundreds of other changes.
JDK 10, about to be released, has new features including one long familiar to C# developers – type inference with the var keyword. This means you can type:
var arr = new ArrayList<String>();
The variable arr is still strongly typed, but the type is inferred from the assignment.
There is also specific support for Docker containers in the JVM so that it will read the container configuration rather than the operating system when detecting what resources are available.
Ritter also mentioned several long-term projects with no release yet set:
- Project Amber: Language changes, including type inference mentioned above, but also pattern matching and more.
- Project Loom: Support for lightweight threads called fibres, and continuations for easier asynchronous coding.
- Project Metropolis: Code part of the JVM runtime itself in Java.
- Project Panama: Improve interop with native code via a new Native InterConnect Layer.
- Project Valhalla: Value types for more efficient code when primitive types are not suitable and object types too expensive.
The price of advancing Java?
Java's new release train is more agile but this comes at a price. More of the burden of keeping applications patched and up to date passes to developers and package maintainers. Oracle is reducing its own maintenance burden and also, perhaps, trying to push more customers towards paid support.
That said, most developers will treat releases like JDK 9 and 10 as software for testing and experimentation rather than production, which makes the pace of the new release cycle look more like the old – though you still need to get your head around Oracle's new approach to public distribution. ®