Modules   «Prev  Next»

Glassfish Example

Here is a real example of some code that does that, namely Glassfish 4.1 does not run on JDK nine because the JVM throws an IllegalAccessError
The error message is
class  com.sun.enterprise.security.provider policy wrapper 
in module unnamed module, cannot access class
com.sun.security.provider policy file 
in module java.base.
Now a glance at the open JDK repository shows us that the policy file class in sun.security is declared public, but because that package is not exported by java.base, policy file is only accessible from code in java.base itself.

Java Classes
Java Classes


To be clear in JDK 9, the GlassFish code cannot access this public policy file class at compile time or runtime.
It is exactly like trying to access a "package private" class.
javac gives an error and the virtual machine throws IllegalAccessError.
GlassFish will have to find a supported API, not one of these concealed sun.* API's.

Reusing a Module

module exports packages, but requires modules

I would like to return to the
module-info.java
file that declares the HelloWorld module.
It is really important to understand that a module
  1. exports packages,
  2. but requires modules.
The reason is due to an old software engineering principle. The "unit of reuse" is the "unit of release".

The unit of reuse is the unit of release.
The "unit of reuse" is the "unit of release".