Encapsulating internal APIs in JDK 9 (sun.misc.Unsafe, etc.)

Simon Nash simon at cjnash.com
Tue Aug 4 19:07:17 UTC 2015


mark.reinhold at oracle.com wrote:
> 2015/8/4 11:34 -0700, simon at cjnash.com:
>> Thanks for this.  In the list of broad categories, one is missing:
>>
>> x  Those which are required to enable application code to work around
>>     bugs in the JDK such as leaked objects.
> 
> That could be an awfully broad category.  Do you have some specific
> examples in mind?
> 
It is a broad category and it is an important one that deserves mention.

I have come across a number of examples of leaked objects in Swing/AWT for
which I have implemented workarounds by using internal APIs and reflection
to locate the relevant fields and set them to null.  At some point, I hope
to create formal bug reports for these.

The main impact is not memory consumption but the holding of references
to my application classloader that prevents it from being garbage collected.
This prevents any native libraries that were loaded by this classloader
from being replaced with updated versions.

>> When do you expect to be able to publish a detailed proposal for how the
>> "last resort" mechanism will work?
> 
> That will be an implementation-specific command-line flag, to be
> proposed in a forthcoming JEP.
> 
> - Mark
> 
I look forward to seeing these details in the forthcoming JEP.

  Simon


More information about the jigsaw-dev mailing list