bas121 - Fotolia
Mark Reinhold, Chief Architect of Java, took the stage during this year's keynote address at JavaOne to provide an update about Java 9. His JavaOne 2017 presentation highlighted the work his team put into making Java less painful to use in today's fast-paced and nimble development world. In particular, he spoke about addressing two key pain points that face enterprise developers: the brittle classpath and the monolith.
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
Modules prove to be the solution
At JavaOne 2017 it was discussed how the team turned to its tried and true method for solving difficult problems like modularity in Java. First, they identified the missing abstraction, then they determined what they would need it to do and how to make it fit in while preserving readability, simplicity, universality, and compatibility—all core values of Java according to Reinhold. "That missing abstraction, as we now know, is modules."
For any developers new to the concept of Java modularity, Mark described in his JavaOne 2017 keynote how modules as, "a set of packages designed for reuse." He went on to outline Java's modular solution. "In Jigsaw, modules are a new construct of the programming language. They work the same way at compile time and runtime because they are known to both the compiler and the VM." He explained the purpose of Jigsaw in simplifying development and providing a cleaner, safer alternative to the classpath—the module-path.
Why module-path beats the hell out of classpath
Besides being easy to deploy autonomously due to loose coupling and having a readily understandable interface, modules offer some high value benefits that classpath never could. In Reinhold's words, "It guarantees two key properties you can't even express, much less guarantee on the classpath." The first property is reliable configuration. "If one module requires another, that other module will be present and none will conflict with any others." With modules, all requirements and dependencies are simple to discover and identify. And if there is a missing element, this becomes readily apparent while building the code—not just at runtime.
The second property is strong encapsulation. "Code outside of a module can only access the classes and interfaces in the packages explicitly exported by that module." This concealment and protection of internal APIs provides a certain measure of security from attack and allows these APIs to be updated as desired. Mark admitted that this encapsulation is relaxed a bit for certain classes that are being phased out, allowing time for enterprises to replace legacy code with more modern versions.
Slicing up the spaghetti bowl
The move from monolith to modules was another crucial challenge for the Java architecture team. Reinhold presented complex charts showing how the original "spaghetti bowl" of platform components in the monolith was eventually broken out into a set of 26 standard Java SE modules, with java.base underlying them all. The benefit is evident and immediate. "Now it is scalable. You can reliably configure subsets using only the necessary components." Mark mentioned that developers can now produce custom runtime systems using Jlink, a new tool in Java 9. The result would be a much faster platform.
What about the Jigsaw haters?
Mark took time to address the notion that, "Jigsaw breaks everything." He confessed that, in fact: "Jigsaw breaks some things." The trick is to understand the risk. Developers working with Java-centric code are not in much danger of having everything explode in their face. "If an existing application runs on JDK 8 and if your code only uses standard Java 8 APIs, then it will most likely work on JDK 9 without change." For those unlucky developers working on code that has obscure, rarely used methods and non-standard APIs, libraries, or dependencies, the risk of problems goes up.
However, according to a survey Reinhold conducted on Twitter prior to the conference, Jigsaw is indeed compatible with a significant portion of the ecosystem from Gradle to Spring and most of the other popular tools, frameworks, and environments. He encouraged developers to run jdeps which can check internals and suggest standard replacements, offering a fairly straightforward way to prepare existing code for the implementation of Java 9.
Jigsaw can be implemented piece by piece
Mark assured audience members that they do not have to convert everything to modular form to start using Jigsaw. It was designed to integrate with legacy systems and can coexist peacefully with classpaths. "Jar files on the classpath can even refer to APIs that are exported by modules on the module-path." This pragmatic approach acknowledged the fact that breaking up a monolith requires more than tools. It takes time. "We know it's going to be a long road to widespread adoption."
In the meantime, the team is busy preparing the language for a future that will see an even faster acceleration in the rate of innovation. In his JavaOne 207 keynote, Reinhold reiterated that Oracle is committed to shipping every six months going forward, greatly reducing the time to launch new and improved features. "It keeps Java moving forward and moving forward faster." Smaller, faster, better. That's the goal of modularity, and next year's conference attendees should discover even more ways to ease their transition into the Jigsaw world of Java development.
Java SE 9, OpenJDK energize Java community at JavaOne 2017
Keynote speakers open up at JavaOne 2017
Java SE 9 a perfect fit for a nimble, scalable and serverless future