< prev index next >

src/java.base/share/classes/java/lang/reflect/ProxyGenerator_v49.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -28,16 +28,15 @@
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.lang.reflect.Array;
-import java.lang.reflect.Method;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.LinkedHashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
 import java.util.Map;
 import sun.security.action.GetBooleanAction;

@@ -50,11 +49,11 @@
  * "generateProxyClass" method.
  *
  * @author      Peter Jones
  * @since       1.3
  */
-class ProxyGenerator {
+class ProxyGenerator_v49 {
     /*
      * In the comments below, "JVMS" refers to The Java Virtual Machine
      * Specification Second Edition and "JLS" refers to the original
      * version of The Java Language Specification, unless otherwise
      * specified.

@@ -317,11 +316,11 @@
 
     /**
      * Generate a public proxy class given a name and a list of proxy interfaces.
      */
     static byte[] generateProxyClass(final String name,
-                                     Class<?>[] interfaces) {
+                                     List<Class<?>> interfaces) {
         return generateProxyClass(name, interfaces, (ACC_PUBLIC | ACC_FINAL | ACC_SUPER));
     }
 
     /**
      * Generate a proxy class given a name and a list of proxy interfaces.

@@ -329,14 +328,14 @@
      * @param name        the class name of the proxy class
      * @param interfaces  proxy interfaces
      * @param accessFlags access flags of the proxy class
     */
     static byte[] generateProxyClass(final String name,
-                                     Class<?>[] interfaces,
+                                     List<Class<?>> interfaces,
                                      int accessFlags)
     {
-        ProxyGenerator gen = new ProxyGenerator(name, interfaces, accessFlags);
+        ProxyGenerator_v49 gen = new ProxyGenerator_v49(name, interfaces, accessFlags);
         final byte[] classFile = gen.generateClassFile();
 
         if (saveGeneratedFiles) {
             java.security.AccessController.doPrivileged(
             new java.security.PrivilegedAction<Void>() {

@@ -381,11 +380,11 @@
 
     /** name of proxy class */
     private String className;
 
     /** proxy interfaces */
-    private Class<?>[] interfaces;
+    private List<Class<?>> interfaces;
 
     /** proxy class access flags */
     private int accessFlags;
 
     /** constant pool of class being generated */

@@ -399,11 +398,11 @@
 
     /**
      * maps method signature string to list of ProxyMethod objects for
      * proxy methods with that signature
      */
-    private Map<String, List<ProxyMethod>> proxyMethods = new HashMap<>();
+    private Map<String, List<ProxyMethod>> proxyMethods = new LinkedHashMap<>();
 
     /** count of ProxyMethod objects added to proxyMethods */
     private int proxyMethodCount = 0;
 
     /**

@@ -411,11 +410,11 @@
      * specified name and for the given interfaces.
      *
      * A ProxyGenerator object contains the state for the ongoing
      * generation of a particular proxy class.
      */
-    private ProxyGenerator(String className, Class<?>[] interfaces, int accessFlags) {
+    ProxyGenerator_v49(String className, List<Class<?>> interfaces, int accessFlags) {
         this.className = className;
         this.interfaces = interfaces;
         this.accessFlags = accessFlags;
     }
 

@@ -538,11 +537,11 @@
             dout.writeShort(cp.getClass(dotToSlash(className)));
                                         // u2 super_class;
             dout.writeShort(cp.getClass(superclassName));
 
                                         // u2 interfaces_count;
-            dout.writeShort(interfaces.length);
+            dout.writeShort(interfaces.size());
                                         // u2 interfaces[interfaces_count];
             for (Class<?> intf : interfaces) {
                 dout.writeShort(cp.getClass(
                     dotToSlash(intf.getName())));
             }
< prev index next >