The true impact of modular Java

Java 9's much anticipated modularity may have less effect on your coding practices than you think

Modularity is coming to Java. But the big fanfare for modularized Java may already be cooling, well in advance of the Java SE 9 release due in late July, thanks to mixed reviews.

Oracle has thus far positioned modularity as a key benefit for the Java platform, in large part because it will enable the JDK (Java Development Kit) to be divided into a set of modules that can be compiled at runtime in a multitude of configurations. That effort should make Java scale down more easily to small devices. Considered a "transitive" direction for the platform, modular Java has been engineered to understand dependencies between modules and will attempt to resolve these transitive dependencies at compile or launch time.

The practical effect of modularity on Java engineer's coding practices could be significant.

"Modules affect all phases of development: compiling, testing, packaging, deploying, running. So they're much more connected to the tools ecosystem than a feature like Lambdas (the focus of JDK 8)," Alex Buckley, specification lead for the Java language and the JVM (Java Virtual machine) at Oracle, said last year during a presentation on Java 9 at a Silicon Valley Java User Group meeting.

Still, an official at Java runtime builder Azul Systems remains ambivalent about modularity's impact.

"I don't think that modularization is going to do much to change how people code or change their coding practices or productivity," says Azul CTO Gil Tene, who has participated in Java's development. He believes it won't bring chages to the extent that Lambda expressions and the Stream API did in Java 8.

Project Jigsaw has been the key to modularizing Java, but that effort has not been without its complications. Initially set for Java Development Kit 8, which was released in March 2014, modularity was delayed until JDK 9, which itself has been delayed as builders wrestle with the intricacies of the module system.

Observers, however, are not fully sold on modularity, and Andy Piper, CTO of Java middleware provider Push Technology, believes the capability could, in fact, be too little, too late. "Java 9 modularity is like the Spruce Goose: conceived in a bygone era, overambitious in scope, and woefully late in delivery," Piper says. "I'm not convinced that the problems it was trying to solve are high on people's priority list anymore, and for those that care, there are already alternate solutions."

Developers will make use of modularity, sure, as they always use what's in the JDK, adds Piper, who has been involved with Java for 20 years. "Will they benefit?" he asks. "Difficult to say. Smaller footprints are good even though device capabilities have radically changed in the 10-plus years since Java modularity was conceived. Modular development is also a good thing but difficult to achieve any useful ROI on without serious commitment and investment."

On the other hand, JetBrains, makers of the popular IntelliJ Idea IDE for Java, is positive on modularity.

"From my own experience of using Java 9 modularity, and my experience as a library developer, making modules a first-class citizen in the language encourages good design practices, and also helps solve the dilemma of how to have code that's somewhere between private and protected," says Trisha Gee, Java technical advocate at JetBrains. "The great thing about the approach the JDK team has taken in introducing modularity in Java is that for the majority of developers, it probably has very little impact on them or their code," she adds.

If code does not use internal APIs, which will be hidden away by modularity in Java 9, everything should work as it used to, Gee says. "There is no need to change an application to use the modular system if it is not needed. But modularity will impact libraries, with many libraries having been forced to use APIs from the JDK internals -- the very APIs that modularity is designed to hide -- in order to provide the features users need."

Developers actually could go overboard with modularity, getting very focused on decomposing a system into modules, which can cause complications, Push Technology's Piper says.

Tene, however, stresses that modularization addresses a concrete deployment concern that Java could do better on.

"But Java is arguably the best environment in the world for that anyway," Tene adds. "So we're fixing something in Java that is broken everywhere else in a much worse way."

For most Java developers, modularization will be "kind of a shoulder shrug," Tene quips.

Related articles

Join the TechWorld newsletter!

Error: Please check your email address.

More about EclipseModularOracleTechnology

Show Comments

Market Place

[]