Interview with Stephen Colebourne

Java 9 and beyond: “Modules are very much a feature for the long-term”

Gabriela Motroc
Java 9

Stephen Colebourne, Java Champion and JAX London speaker is very excited about the upcoming Java 9 release and the imminent modular future. Project Jigsaw should have been a major feature of Java 8 but now it’s ready for public display. Therefore, it’s time to consider how it might affect existing and new codebases. We talked to Stephen about the new Java 9 and the star of the show, Project Jigsaw.

JAXenter: Georges Saab, chairperson of the OpenJDK governing board and vice president of development for the Java Platform Group at Oracle told us in early June that many developers will probably get started on JDK 9 without modules. How do you feel about the modular ecosystem?

Stephen Colebourne: The Java Platform Module System (JPMS) is not perfect, but it has reached a point where it is worth releasing. Most developers can continue to use the classpath, and be unaffected by the module changes. Dodgy reflection practices will be the main issue, with some library upgrades necessary to solve them. I’m happy enough that the module system work is winding down, as I personally think there are some other big language challenges that have been delayed too long.

JAXenter: This major new feature is long overdue but now that it’s finally happening, how will it affect existing and new codebases?

Stephen Colebourne: In both cases, there is little a developer can do until their dependencies are at least partially modularized. While automatic modules, in theory, allow use of the module system immediately, in practice it is better to wait until dependencies are modularized. What does matter for new codebases is to have a plan for modularization. Structure code into Maven-style projects and ensure that no package is in two modules. This will prepare the way for adding files later.

Applying Jigsaw to a mature codebase will likely be very challenging.

JAXenter: There will definitely be Java 9 features that pose a challenge to developers but is Jigsaw one of them? What features, if any, do you find particularly challenging?

Stephen Colebourne: Applying Jigsaw to a mature codebase will likely be very challenging. It may well be so challenging that it will not be worth doing. Modules are very much a feature for the long-term.

SEE MORE: “Java 9 is much bigger than Jigsaw”

JAXenter: Can you give us some examples of how modules can improve the Java 9 experience?

Stephen Colebourne: If you can get to a system where your code is modularized and all your dependencies are modularized, then your code will take a step forward in stability and encapsulation. After 20 years, the JVM will actually understand jar file (module) boundaries and respect/enforce them. This is a kind of “tough love”, but will result in better solutions.

JAXenter: Even though Mark Reinhold said at the last JavaOne keynote that Java 9 is much bigger than Jigsaw, this feature is undoubtedly the star of the release. But what about those other JEPs? Which one do you like best?

Stephen Colebourne: Private methods on interfaces. The ability to add static and default methods to interfaces has really changed how I design APIs. Having private methods will help that even more. But I do encourage people to always write “public static”, “public abstract” or “public default” on interfaces now to gain clarity.

JAXenter: There’s a new project by Nicolai Parlog called WTF, Java 9 where he collects short, self-contained, correct (or not) examples demonstrating what fails [in Java 9]and how to fix the hiccups. What problems have you personally encountered when experimenting with Java 9 and how did you fix the problem?

Stephen Colebourne: I tried some very early versions and lots didn’t work. I’ve not encountered any significant problems recently.

SEE MORE: Java 9 misconceptions & Java 10 wish list: A tell-it-all interview with Java influencers

JAXenter: What is the most important misconception about Java 9? How about Jigsaw?

Stephen Colebourne: Most existing Java code will continue to work on Java 9. The classpath still exists. Modules are opt-in. And in my opinion, most application developers should ignore the module system until their dependencies have been at least partially modularized. So, the key misconception is that everything will suddenly fail, when in fact it won’t be much worse than many other Java version upgrades.

JAXenter: Is Jigsaw a worthy opponent to JBoss Modules and OSGi? Why should developers pick Jigsaw over JBoss Modules and OSGi?

Stephen Colebourne: The Java Platform Module System does not really have that much in common with OSGi. The OSGi module system is best used for dynamic modules – ie. an ecosystem where modules can appear and disappear during the JVMs lifetime. It also handles complex cases like having two versions of the same jar in memory at the same time. These complexities are not needed by most systems, and it is good that the platform module system does not go that far. I’ve not used JBoss modules, so I can’t comment.

The key misconception [about Java 9] is that everything will suddenly fail, when in fact it won’t be much worse than many other Java version upgrades.

JAXenter: What would you like to see in Java 10?

Stephen Colebourne: I hope Java 10 will arrive a lot faster than Java 9. As such, I expect it will contain a lot less changes. What I am looking forward to in a future version (not Java 10) is data classes extending to the use cases that developers use POJOs/beans for today. This would be a huge beneficial change for Java.

JAXenter: What will attendees get out of your talk?

Stephen Colebourne: My Java SE 9 Modules talk explains the design of the Module system, and how to modularize your own code while pointing out the pitfalls. I always find it is the ‘gotchas’ that are the most interesting part to explain and the most useful to attendees.

Stephen Colebourne will be delivering one talk at JAX London which will focus on the basics of the Java platform module system and its implications, particularly to reflection.

turn around bright eyes

To find out more about Java 9 and modularity, download the latest issue of JAX Magazine:

What comes to your mind when you hear the word Java? How about blockchain, DevOps and microservices? If you want to learn about emerging technologies or dive deeper into topics you’re already familiar with (I’m looking at you Java 9), what better way to do that than to go straight to the source?

Open the magazine and allow the experts (all 14 of them) to shower you with information.

Gabriela Motroc
Gabriela Motroc was editor of and JAX Magazine. Before working at Software & Support Media Group, she studied International Communication Management at the Hague University of Applied Sciences.

Inline Feedbacks
View all comments