Accessing internal packages in JDK 9

mark.reinhold at oracle.com mark.reinhold at oracle.com
Tue Jul 28 15:22:23 UTC 2015


2015/7/28 8:12 -0700, Simon Nash <simon at cjnash.com>:
> mark.reinhold at oracle.com wrote:
>> 2015/7/28 4:21 -0700, Simon Nash <simon at cjnash.com>:
>>> ...
>>> 
>>> With JDK 9 and Project Jigsaw, I understand that it will no longer be
>>> possible for my application to directly reference internal sun.* classes.
>>> Will it still be possible to use ClassLoader.loadClass to load these sun.*
>>> classes and use reflection to invoke their methods?
>> 
>> Yes, but you'll have to use a command-line flag to make the classes
>> accessible via the reflection API.
> 
> Is this a single option that enables all internal access or does the option
> need to be repeated for every internal package or class that the application
> needs to access?
> 
> If the option is set, can the application use imports for the internal
> packages or is it required to access them reflectively?
> 
> Would it be possible to allow the application to set this option
> programmatically on initialization or set it internally in some other way
> (e.g., in its jar manifest) so that the users of the application don't need
> to specify it on the launch command?

These are all good questions.  We're nearly done drafting a JEP which
will answer them, so rather than answer them here can I ask that you
read the JEP when it's published?

Thanks,
- Mark


More information about the jigsaw-dev mailing list