Review Request JDK-8202113: Reflection API is causing caller classes to leak

mandy chung mandy.chung at
Sat Apr 28 09:44:52 UTC 2018


The reflection machinery stores the caller class in each AccessibleObject
such that it can skip the access check if access to a member has been
verified for a given caller.  At the first time accessing the 
it creates an Accessor object and then cache for subsequent use.  This 
Accessor object keeps a reference to the AccessibleObject object that
will keep the caller class alive.

The implementation has a root object for each AccessibleObject and
the API returns a child object for users to access (that may suppress
access check via setAccessible). The caller class is set in the cache
of the child object.  This patch proposes to change ReflectionFactory
newXXXAccessor methods to ensure to pass the root object rather than
the child object.  The cache of the root object is always null.


More information about the core-libs-dev mailing list