--- a/src/java.base/share/classes/java/lang/reflect/Proxy.java Thu Oct 04 16:39:07 2018 +0200
+++ b/src/java.base/share/classes/java/lang/reflect/Proxy.java Thu Oct 04 08:45:21 2018 -0700
@@ -39,12 +39,11 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicLong;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
import jdk.internal.loader.BootLoader;
+import jdk.internal.misc.JavaLangAccess;
+import jdk.internal.misc.SharedSecrets;
import jdk.internal.module.Modules;
-import jdk.internal.misc.Unsafe;
import jdk.internal.misc.VM;
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
@@ -468,7 +467,7 @@
* in which the proxy class will be defined.
*/
private static final class ProxyBuilder {
- private static final Unsafe UNSAFE = Unsafe.getUnsafe();
+ private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess();
// prefix for all proxy class names
private static final String proxyClassNamePrefix = "$Proxy";
@@ -535,9 +534,8 @@
byte[] proxyClassFile = ProxyGenerator.generateProxyClass(
proxyName, interfaces.toArray(EMPTY_CLASS_ARRAY), accessFlags);
try {
- Class<?> pc = UNSAFE.defineClass(proxyName, proxyClassFile,
- 0, proxyClassFile.length,
- loader, null);
+ Class<?> pc = JLA.defineClass(loader, proxyName, proxyClassFile,
+ null, "__dynamic_proxy__");
reverseProxyCache.sub(pc).putIfAbsent(loader, Boolean.TRUE);
return pc;
} catch (ClassFormatError e) {