Accessibility is the other side of the Java modularity coin. If the readability relationship specifies what modules can read a given module, accessibility indicates what they actually do get when they read it. Not everything in a module is accessible to the other modules that read it. Only the public types in packages that are marked with an exports declaration are.
Thus, for a type in module B to be accessible in module A, the following needs to happen:
- Module A needs to read module B
- Module B needs to export the package that contains the type
- The type itself should be public
Let's look at an example and examine the readability and accessibility relationships. Consider two modules, app and lib. Module app has a requires qualifier for module lib. Module lib exports its package lib.external:
module app { requires lib; } module lib...