hg: jdk8/tl/jdk: 7194897: JSR 292: Cannot create more than 16 instances of an anonymous class; ...

Peter Levart peter.levart at gmail.com
Tue Nov 5 00:25:57 PST 2013


Hi Robert,

I think this fix is not complete. When one sets the system property 
sun.reflect.noInflation=true, reflection proxy is still attempted to be 
generated for anonymous classes (see 
ReflectionFactory.newMethodAccessor/newConstructorAccessor).

I would also restructure the Method/Constructor accessor logic 
differently. The check for ReflectUtil.isVMAnonymousClass() can be 
performed just once (in the newMethodAccessor/newConstructorAccessor 
methods) and based on this check, create accessor:

- for classic declaring class - as is / unchanged
- for anonymous declaring class - just create and return 
NativeMethodAccessorImpl without a parent

Then in NativeMethodAccessorImpl (and same for constructor), modify the 
inflation checking logic:

         if (*parent != null && *++numInvocations > 
ReflectionFactory.inflationThreshold()) {
             MethodAccessorImpl acc = (MethodAccessorImpl)
                 new MethodAccessorGenerator().
generateMethod(method.getDeclaringClass(),
                                    method.getName(),
method.getParameterTypes(),
method.getReturnType(),
method.getExceptionTypes(),
method.getModifiers());
             parent.setDelegate(acc);
         }

Regards, Peter

On 11/04/2013 07:12 PM, robert.field at oracle.com wrote:
> Changeset: 51b002381b35
> Author:    rfield
> Date:      2013-11-04 10:12 -0800
> URL:       http://hg.openjdk.java.net/jdk8/tl/jdk/rev/51b002381b35
>
> 7194897: JSR 292: Cannot create more than 16 instances of an anonymous class
> 8027681: Lambda serialization fails once reflection proxy generation kicks in
> Reviewed-by: ksrini, briangoetz, jfranck
> Contributed-by: joel.franck at oracle.com, brian.goetz at oracle.com, robert.field at oracle.com
>
> ! src/share/classes/sun/reflect/NativeConstructorAccessorImpl.java
> ! src/share/classes/sun/reflect/NativeMethodAccessorImpl.java
> ! src/share/classes/sun/reflect/misc/ReflectUtil.java
> + test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java
> ! test/java/util/stream/test/org/openjdk/tests/java/lang/invoke/SerializedLambdaTest.java
> + test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/security-dev/attachments/20131105/843ef925/attachment.html 


More information about the security-dev mailing list