--- a/src/java.base/share/classes/java/lang/reflect/Proxy.java Thu Oct 17 20:27:44 2019 +0100
+++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java Thu Oct 17 20:53:35 2019 +0100
@@ -49,6 +49,7 @@
import jdk.internal.reflect.Reflection;
import jdk.internal.loader.ClassLoaderValue;
import sun.reflect.misc.ReflectUtil;
+import sun.security.action.GetBooleanAction;
import sun.security.action.GetPropertyAction;
import sun.security.util.SecurityConstants;
@@ -99,7 +100,7 @@
* <li>A proxy class extends {@code java.lang.reflect.Proxy}.
*
* <li>A proxy class implements exactly the interfaces specified at its
- * creation, in the same order. Invoking {@link Class#getInterfaces getInterfaces}
+ * creation, in the same order. Invoking {@link Class#getInterfaces() getInterfaces}
* on its {@code Class} object will return an array containing the same
* list of interfaces (in the order specified at its creation), invoking
* {@link Class#getMethods getMethods} on its {@code Class} object will return
@@ -282,6 +283,7 @@
* @spec JPMS
*/
public class Proxy implements java.io.Serializable {
+ @java.io.Serial
private static final long serialVersionUID = -2222568056686623797L;
/** parameter types of a proxy class constructor */
@@ -296,9 +298,17 @@
new ClassLoaderValue<>();
/**
+ * System property to revert to generation of proxy class files for version 1.5 (V49).
+ * Set to "true" to generate v49 class file format.
+ */
+ private static final boolean PROXY_GENERATOR_V49 =
+ GetBooleanAction.privilegedGetProperty("jdk.proxy.ProxyGenerator.v49");
+
+ /**
* the invocation handler for this proxy instance.
* @serial
*/
+ @SuppressWarnings("serial") // Not statically typed as Serializable
protected InvocationHandler h;
/**
@@ -531,8 +541,9 @@
/*
* Generate the specified proxy class.
*/
- byte[] proxyClassFile = ProxyGenerator.generateProxyClass(
- proxyName, interfaces.toArray(EMPTY_CLASS_ARRAY), accessFlags);
+ byte[] proxyClassFile = PROXY_GENERATOR_V49
+ ? ProxyGenerator_v49.generateProxyClass(proxyName, interfaces, accessFlags)
+ : ProxyGenerator.generateProxyClass(loader, proxyName, interfaces, accessFlags);
try {
Class<?> pc = JLA.defineClass(loader, proxyName, proxyClassFile,
null, "__dynamic_proxy__");
@@ -1116,6 +1127,5 @@
return ih;
}
- private static final Class<?>[] EMPTY_CLASS_ARRAY = new Class<?>[0];
private static final String PROXY_PACKAGE_PREFIX = ReflectUtil.PROXY_PACKAGE;
}