8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true
Reviewed-by: briangoetz
--- 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;
/** <P> 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(),
--- 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;
}
}
--- 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.*;
--- 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;