--add-opens for entire module

Andrew Guibert aguibert at us.ibm.com
Wed Dec 28 07:30:56 UTC 2016

In the currently accepted proposal for #ReflectiveAccessToNonExportedTypes
[1], it is described that an entire module can be opened with the following

open module foo.bar {
    exports com.foo.bar;
    requires hibernate.core;
    requires hibernate.entitymanager;

The current syntax for --add-opens option is:

  --add-opens <module>/<package>=<target-module>(,<target-module>)*

Namely, the --add-opens option can only be used to open specific packages
from a module, whilst in a module-info.java it is possible to open an
entire module with a single directive. Therefore, I would like to propose
altering the --add-opens option to more closely match what is achievable in
a module-info file, such as:

  --add-opens <module>[/<package>]=<target-module>(,<target-module>)*

So if a <package> is not specified, the entire module would be open for
deep reflection at run time.

Being able to open an entire module with a single JVM option will ease the
migration of existing java programs to the new modular JDK. Specifically,
it will allow developers to get our programs up and running in "toleration"
mode more quickly, and then tackle a fine-grained set of open packages on a
per-module basis.


More information about the jigsaw-dev mailing list