RFR(S) 8226645: [TESTBUG] some AppCDS tests relies on illegal reflective access

Alan Bateman Alan.Bateman at oracle.com
Mon Aug 12 06:42:01 UTC 2019


On 12/08/2019 06:19, David Holmes wrote:
>
> I don't understand how this works. MethodHandles.lookup() returns a 
> Lookup for the current/caller class, which in this case is the Utils 
> test library class. You then use that Lookup instance to try and get a 
> private Lookup for peerClass, which is an arbitrary test class. But 
> the Utils Lookup should not have permissions to get a private Lookup 
> for an arbitrary class! Unless there is some kind of "un-named module" 
> general access being granted here ??
It will only work id peerClass's module opens the packages to all 
unnamed modules. A saner approach might be for the Util method to take a 
Lookup object with the right access so that it defines the class in the 
same run-time package as the lookup object. In addition, tests such as 
LoaderSegregation create the ClassLoader so they can define the class 
(C2 in this case) directly, no need for a dummy class.

-Alan


More information about the hotspot-runtime-dev mailing list