The module system planned for debut in next year's Java SE (Standard Edition) 9 platform will treat modules as a fundamental new kind of program component, with the system improving scalability and performance, a key Oracle Java official says.
In a blog post this week, Oracle's Mark Reinhold, chief architect of the Java platform group, discussed the goals of the module system. Chief among them is reliable configuration, to replace the "brittle, error-prone, class-path mechanism" with a means for program components to declare dependencies on each other. Strong encapsulation, which allows a component to declare which public types are accessible to other components, is also a goal.
"These features will benefit application developers, library developers, and implementers of the Java SE Platform itself directly," said Reinhold, "and indirectly, since they will enable a scalable platform, greater platform integrity, and improved performance."
Reinhold defined a module as a self-describing collection of code and data. Code within it is organized as a set of packages containing types, essentially classes, and interfaces. Data within modules includes resources and other kinds of static information.
The module system has many facets, but most developers will require only some of them on a regular basis. "We expect the basic concepts of module declarations, modular JAR files, module graphs, module paths and unnamed modules to become reasonably familiar to most Java developers in the coming years," Reinhold explained. "The more advanced features of qualified exports, increasing readability, and layers will, by contrast, be needed by relatively few."
Platform modules are slated to include the base module, called java.base; other platforms modules likely include java.sql, for database connectivity; java.xml, for XML processing; and java.logging, for logging. "The only module known specifically to the module system, in any case, is the base module," Reinhold said. "The base module defines and exports all of the platform's core packages, including the module system itself."
Key to the module system is Project Jigsaw, an OpenJDK effort intended to make Java SE and the Java Development Kit more easily scalable to smaller devices. Jigsaw also is geared toward improving security and performance and simplifying the construction and maintenance of libraries and large applications for both Java SE and EE.
Jigsaw is an important step in Java's evolution, analyst Jeffrey Hammond, of Forrester Research, said in an email. Modularity should help Java, especially if it comes with a package manager similar to Node.js's npm or .Net's NuGet, he noted. "Devs have been working around the lack of modules for years. OSGI was an attempt to fix it externally, but it's really something that should be a core part of the language -- and that's what Jigsaw will fix. In some ways it reminds me of one of the strengths of Ada Packages."
Project Jigsaw had been planned for Java SE 8, released last year. But it was delayed until Java 9 to give developers more time to evaluate what Reinhold has described as a "profound change" to Java. The modularization recently caused a controversy when, as part of the process, the proposed elimination of private APIs, particularly sun.misc.Unsafe, upset some key developers. Oracle then amended its plan to allow for a few unsupported APIs, including sun.misc.Unsafe, accessible in Java 9.
This story, "Oracle says Java 9 modules will be a boon for developers" was originally published by InfoWorld.