Before Java 9, reflection could be used to learn about all types in a package and all members of a type—even its private members.
Thus, nothing was truly encapsulated.
Allowing runtime-only access to a package.
An opens module directive of the form:
indicates that a specific package’s public types (and their nested public and protected types) are accessible to code in other modules at runtime only.
Also, all the types in the specified package (and all of the types’ members) are accessible via reflection.
Allowing runtime-only access to a package by specific modules.
Use an opens…to module directive of the form:
Allowing runtime-only access to all packages in a module.
If all the packages in a given module should be accessible at runtime and via reflection to all other modules, use:
We just sent you an email. Please click the link in the email to confirm your subscription!