Project Jigsaw

is the name of the project to build a Java Platform Module System (JPMS) into the Java 9 platform.

Modularizing the Java SE platform has been challenging to implement, and the effort has taken many years.
  • JSR 277: Java Module System was originally proposed in 2005 for Java 7.
  • This JSR was later superseded by JSR 376: Java Platform Module System and targeted for Java 8.
  • The Java SE platform is modularized in Java 9, but only after Java 9 was delayed until September 2017.
The Java platform is modularized into numerous modules in Java 9. The number of modules will clearly change with the new features added to the platform.
Developers can now create custom runtimes consisitng of the only modules needed by the target application. For example, if the application is cli-based, then the runtime might not include the GUI modules and this will considerably reduce the size of runtime.

1. Competitors 

  • JBoss Modules
  • OSGi (extremely complicated)

2. JEPs & JSRs

JEP 200: The Modular JDK
  • Divide the JDK into a set of modules that can be combined at compile time, build time, and run time into a variety of configurations
JEP 201: Modular Source Code
  • Reorganize the JDK source code into modules, enhance the build system to compile modules, and enforce module boundaries at build time.
JEP 220: Modular Run-Time Images
  • Restructure the JDK and JRE run-time images to accommodate modules and to improve performance, security, and maintainability.
JEP 260: Encapsulate Most Internal APIs
  • Encapsulate most of the JDK's internal APIs by default so that they are inaccessible at compile time, and prepare for a future release in which they will be inaccessible at run time.
JEP 261: Module System
JEP 282: jlink: The Java Linker
  • Create a tool that can assemble and optimize a set of modules and their dependencies into a custom run-time image as defined in JEP 220.
JSR 376: Java Platform Module System
JSR 379: Java SE 9 Platform Umbrella

3. Java 9 Platform Module System (JPMS)

A module is formed of reusable group of related code, packages and resources(such as XML files).

A module descriptor declares the following properties of the module: 

  • module name
  • dependencies that the module depends on
  • the packages that is made available to other modules
  • offered services
  • consumed services

3.1 Listing the JDK's Modules

  • java --list-modules
  • Names starts with java includes the standard modules that implement the Java Language SE Specification
  • Names starting with javafx JavaFX modules
  • Names starting with jdk JDK-specific modules
  • Names starting with oracle Oracle-specific modules
  • Each module name is followed by a version string—@9 indicates that the module belongs to Java 9

3.2 Module Decleration

Module decleration is done in a file named
module modulename { } 

3.3 Module Directives

  • specifies that this module depends on another module
  • this relationship is called a module dependency.
  • requires modulename;
  • requires static
    • a module is required at compile time, but is optional at runtime.
  • requires transitive modulename;
    • known as implied readability
    • specify a dependency on another module
    • and to ensure that other modules reading your module also read that dependency
  • specifies one of the module's packages whose public types (and their nested public and protected types) should be accessible to code in all other modules.
  • exports…to directive enables you to specify in a comma-separated list precisely which module’s or modules’ code can access the exported package—this is known as a qualified export.
provides… with
  • specifies that a module provides a service implementation
  • makes the module a service provider
  • specifies a service used by this module
  • makes the module a service consumer
  • a service is an object of a class that implements the interface or extends the abstract class specified in the uses directive.
  • Allows runtime-only access to a package.
  • opens package
  • opens package to comma-seperated-modules
  • open module module-name

3.4 Module Naming Conventions

  • Like package names, module names must be unique.
  • Typically begin the name with the organization's domain name in reverse order.
  • If a module contains the packages
    • com.test.jtudy.pk1
    • com.test.jtudy.pk2
    • then, you would typically name the module with the common portion of the package names
      • com.test.jtudy

3.5 Module Descriptior

  • Compiling the module declaration creates the module descriptor,
  • which is stored in a file named module-info.class
  • in the module’s root folder.

Viewing the module's description
  • java --module-path mods --describe-module com.test.jtudy



Java EE Technology Stack

Dependency Injection In Java and CDI

Proxy Server