Java Module System

The Java Module System specifies a distribution format for collections of Java code and associated resources. It also specifies a repository for storing these collections, or modules, and identifies how they can be discovered, loaded and checked for integrity. It includes features such as versioning and namespaces with the aim of fixing some of the shortcomings in the existing JAR format, especially the JAR Hell, which can lead to issues such as classpath and class loading problems.

The Java Module System was initially being developed under the Java Community Process as JSR 277 and was scheduled to be released with Java 7.

JSR 277 later was put on hold and Project Jigsaw[1] was created to modularize the JDK.[2] This JSR was superseded by JSR 376 (Java Platform Module System).

Project Jigsaw was originally intended for Java 7 (2011) but was deferred to Java 8 (2014) as part of Plan B,[3] and again deferred to a Java 9 release in 2017.[4]

Architecture

The Java Module System implemented for Java 9 will include the following JEPs and JSR (Java Specification Request):[1]

Modules are a new way of grouping code and data. Contrary to Jar files, modules explicitly declare which modules they depend on, and what packages they export.[7]

For example, the following module declaration declares that the module com.foo.bar depends on another com.foo.baz module, and exports the following packages: com.foo.bar.alpha and com.foo.bar.beta:

module com.foo.bar {
    requires com.foo.baz;
    exports com.foo.bar.alpha;
    exports com.foo.bar.beta;
}

Contrary to the Jar file format, the module will describe these dependencies in a module declaration which will be placed in a file named module-info.java at the root of the module’s source-file hierarchy. The JDK will able to check them both at compile-time and runtime. The JDK itself will be modularized for Java 9.[8]

Links with OSGI

The Java Module System does not intend to support all the functionalities that the OSGi platform currently supports (for example the Life-Cycle model and the Services Registry). However the Java Module System will support functions which are not supported by OSGi, such as modularity at compile-time, and built-in support for native libraries.[9]

See also

References

  1. 1 2 "Project Jigsaw". Oracle Corporation. Retrieved 2015-11-29.
  2. Mark Reinhold (2008-12-02). "Project Jigsaw". Oracle Corporation. Retrieved 2015-11-29.
  3. Mark Reinhold (2008-12-02). "It's time for … Plan B". Oracle Corporation. Retrieved 2015-11-29.
  4. "JDK 9". Oracle Corporation. Retrieved 2016-02-24.
  5. "jlink: The Java Linker (JSR 282)". Oracle Corporation. Retrieved 2016-03-12.
  6. "Java Platform Module System (JSR 376)". Oracle Corporation. Retrieved 2015-11-29.
  7. Mark Reinhold (2015-09-08). "The State of the Module System". Oracle Corporation. Retrieved 2015-11-29.
  8. "JDK Module Summary". Oracle Corporation. 2015-10-23. Retrieved 2015-11-29.
  9. Mark Reinhold (2012-08-24). "Project Jigsaw: Late for the train: The Q&A". Oracle Corporation. Retrieved 2015-11-29.

External links

This article is issued from Wikipedia - version of the 4/29/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.