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

Ioi Lam ioi.lam at oracle.com
Fri Aug 9 20:07:03 UTC 2019


Hi Calvin,

This makes it hard to tell where the privateLookupIn is from.

     import static java.lang.invoke.MethodHandles.*;
     ....
     Lookup lookup = privateLookupIn(target, lookup());

I think it's better to do this:

     import static java.lang.invoke.MethodHandles;
     ....
     Lookup lookup = MethodHandles.privateLookupIn(target, 
MethodHandles.lookup());


Also, instead of forcing every test case to carry a class called 
"Hello", I think
it's better to do this:


     /**
      * Define the class as stored in clsFile, in the same loader as 
peerClass,
      * with the following modification:
      * <ul>....</ul>
      */
     public static Class<?> defineModifiedClass(Class<?> peerClass, File 
clsFile,
                            String fromString, String toString)
         throws .....
     {
         ....
         Lookup lookup = MethodHandles.privateLookupIn(peerClass, 
MethodHandles.lookup());
         Class<?> cls = lookup.defineClass(buff);
         ....

Then the caller of defineModifiedClass can be changed from:

Class superClass = 
Util.defineModifiedClass(RewriteBytecodes.class.getClassLoader(), 
clsFile, from, to);

to

Class superClass = Util.defineModifiedClass(RewriteBytecodes.class, 
clsFile, from, to);

Thanks
- Ioi



On 8/9/19 11:19 AM, Calvin Cheung wrote:
> bug: https://bugs.openjdk.java.net/browse/JDK-8226645
>
> webrev: http://cr.openjdk.java.net/~ccheung/8226645/webrev.00/
>
> Updating couple of AppCDS tests to use Lookup.defineClass instead of 
> ClassLoader.defineClass. A dummy class will be loaded by the requested 
> class loader and then a lookup instance is obtained using the 
> privateLookupIn API.
>
> Testing: mach5 tiers1 - 3.
>
>              locally on linux-x64 with -vmoption:--illegal-access=deny
>
> thanks,
>
> Calvin
>



More information about the hotspot-runtime-dev mailing list