JDK-8205169 : Re-examine policy for the default set of modules when compiling or running code on the class path
  • Type: CSR
  • Component: core-libs
  • Sub-Component: java.lang.module
  • Priority: P3
  • Status: Closed
  • Resolution: Approved
  • Fix Versions: 11
  • Submitted: 2018-06-18
  • Updated: 2018-06-22
  • Resolved: 2018-06-22
Related Reports
CSR :  
Description
Summary
-------

Change the default set of root modules when compiling code or running code on the class path to be all observable system modules that export an API.


Problem
-------

JEP 261 defines the default set of root modules when compiling code in the unnamed module, or the java launcher is invoked and the main class of the application is loaded from the class path, as follows:

- The `java.se` module is a root, if it exists. If it does not exist then every java.* module on the upgrade module path or among the system modules that exports at least one package, without qualification, is a root.

- Every non-java.* module on the upgrade module path or among the system modules that exports at least one package, without qualification, is also a root.

This policy is problematic when creating a run-time image that contains `java.se` and also contains a java.*  module that is not in Java SE but exports an API, e.g. `java.json`. When compiling or running non-modular code, a developer needs to specify `--add-modules` to ensure that the non-Java SE java.* modules in the run-time image are resolved.

A second point is that the original policy was created to ensure that the `java.corba` and Java EE modules (that existed in Java SE 9 and 10)  were not resolved by default.  These modules are proposed to be dropped from Java SE 11 so this aspect of the policy is no longer relevant.


Solution
--------

Change the policy so that the default set of root modules is simply all observable modules on the upgrade module path or among the system modules that exports at least one package, without qualification.

At compile-time, the JDK 9/10 policy for root modules will still be used when targeting 9 and 10 with `--release`.


Specification
-------------

The default set of root modules for the unnamed module is JDK-specific. There are no specifications or normative text to update. The package description for `java.lang.module` does have non-normative text that changes from:

"In the JDK implementation it is the module java.se, if observable and every observable module that exports an API"

to

"In the JDK the default set of root modules contains every module that is observable on the upgrade module path or among the system modules, and that exports at least one package without qualification."

Comments
Moving to Approved.
22-06-2018