提交 18a6d032 编写于 作者: J jfranck

8028055: (reflect) invoking Method/Constructor in anonymous classes breaks...

8028055: (reflect) invoking Method/Constructor in anonymous classes breaks with -Dsun.reflect.noInflation=true
Reviewed-by: briangoetz
上级 30d96879
......@@ -33,6 +33,7 @@ import java.lang.reflect.Modifier;
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 class ReflectionFactory {
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 @@ public class ReflectionFactory {
return new BootstrapConstructorAccessorImpl(c);
}
if (noInflation) {
if (noInflation && !ReflectUtil.isVMAnonymousClass(c.getDeclaringClass())) {
return new MethodAccessorGenerator().
generateConstructor(c.getDeclaringClass(),
c.getParameterTypes(),
......
......@@ -305,6 +305,6 @@ public final class ReflectUtil {
* (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;
}
}
......@@ -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.*;
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册