Access to the internal classes of the module is not possible from the code. This is special. But there is a temporary solution from the command line - a non-standard option in java that does what you want:
--add-exports <module>/<package>=<target-module>(,<target-module>)* updates <module> to export <package> to <target-module>, regardless of module declaration. <target-module> can be ALL-UNNAMED to export to all unnamed modules.
Note
Java 9 is a moving target, and the exact syntax has been changed a couple of times - like this answer. This means that (a) some of the comments below may seem outdated and (b) the flag may not work like that. Please leave a comment and it will be fixed.
source share