# HG changeset patch # User jfranck # Date 1384427857 -3600 # Node ID 33014eb0cb798f1323aba97867f4ff9d811044f1 # Parent f297938a5da709c46568382a0981d74bd7be092d 8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true Reviewed-by: briangoetz diff -r f297938a5da7 -r 33014eb0cb79 jdk/src/share/classes/sun/reflect/ReflectionFactory.java --- a/jdk/src/share/classes/sun/reflect/ReflectionFactory.java Thu Nov 14 10:40:33 2013 +0000 +++ b/jdk/src/share/classes/sun/reflect/ReflectionFactory.java Thu Nov 14 12:17:37 2013 +0100 @@ -33,6 +33,7 @@ import java.security.AccessController; import java.security.Permission; import java.security.PrivilegedAction; +import sun.reflect.misc.ReflectUtil; /**
The master factory for all reflective objects, both those in java.lang.reflect (Fields, Methods, Constructors) as well as their @@ -144,7 +145,7 @@ public MethodAccessor newMethodAccessor(Method method) { checkInitted(); - if (noInflation) { + if (noInflation && !ReflectUtil.isVMAnonymousClass(method.getDeclaringClass())) { return new MethodAccessorGenerator(). generateMethod(method.getDeclaringClass(), method.getName(), @@ -181,7 +182,7 @@ return new BootstrapConstructorAccessorImpl(c); } - if (noInflation) { + if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) { return new MethodAccessorGenerator(). generateConstructor(c.getDeclaringClass(), c.getParameterTypes(), diff -r f297938a5da7 -r 33014eb0cb79 jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java --- a/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Thu Nov 14 10:40:33 2013 +0000 +++ b/jdk/src/share/classes/sun/reflect/misc/ReflectUtil.java Thu Nov 14 12:17:37 2013 +0100 @@ -305,6 +305,6 @@ * (not to be confused with a Java Language anonymous inner class). */ public static boolean isVMAnonymousClass(Class> cls) { - return cls.getSimpleName().contains("/"); + return cls.getName().indexOf("/") > -1; } } diff -r f297938a5da7 -r 33014eb0cb79 jdk/test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java --- a/jdk/test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java Thu Nov 14 10:40:33 2013 +0000 +++ b/jdk/test/java/lang/invoke/lambda/RepetitiveLambdaSerialization.java Thu Nov 14 12:17:37 2013 +0100 @@ -27,6 +27,7 @@ * @summary Lambda serialization fails once reflection proxy generation kicks in * @author Robert Field * @run main/othervm RepetitiveLambdaSerialization + * @run main/othervm -Dsun.reflect.noInflation=true RepetitiveLambdaSerialization */ import java.io.*; diff -r f297938a5da7 -r 33014eb0cb79 jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java --- a/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Thu Nov 14 10:40:33 2013 +0000 +++ b/jdk/test/sun/reflect/AnonymousNewInstance/ManyNewInstanceAnonTest.java Thu Nov 14 12:17:37 2013 +0100 @@ -30,6 +30,7 @@ * @compile -XDignore.symbol.file ManyNewInstanceAnonTest.java * @run main ClassFileInstaller ManyNewInstanceAnonTest * @run main/othervm -Xbootclasspath/a:. -Xverify:all ManyNewInstanceAnonTest + * @run main/othervm -Xbootclasspath/a:. -Xverify:all -Dsun.reflection.noInflation=true ManyNewInstanceAnonTest */ import java.io.ByteArrayOutputStream; import java.io.InputStream;