8153895: (proxy) redundant read edges to superinterfaces of proxy interfaces
authormchung
Wed, 13 Apr 2016 11:03:16 -0700
changeset 37349 648609dc0f3d
parent 37348 9ccec3170d5e
child 37350 944a8584d0fb
8153895: (proxy) redundant read edges to superinterfaces of proxy interfaces Reviewed-by: sundar, plevart
jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Wed Apr 13 10:20:40 2016 -0700
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Proxy.java	Wed Apr 13 11:03:16 2016 -0700
@@ -689,13 +689,14 @@
         }
 
         /*
-         * Returns all types referenced by all public method signatures of
+         * Returns all types referenced by all public non-static method signatures of
          * the proxy interfaces
          */
         private static Set<Class<?>> referencedTypes(ClassLoader loader,
                                                      List<Class<?>> interfaces) {
             return interfaces.stream()
                  .flatMap(intf -> Stream.of(intf.getMethods())
+                                        .filter(m -> !Modifier.isStatic(m.getModifiers()))
                                         .flatMap(ProxyBuilder::methodRefTypes)
                                         .map(ProxyBuilder::getElementType)
                                         .filter(t -> !t.isPrimitive()))
@@ -795,26 +796,13 @@
             // map to dynamic proxy module and add reads edge and qualified exports, if necessary
             Module target = getDynamicModule(loader);
 
-            // set up proxy class access to proxy interfaces and superinterfaces
-            Deque<Class<?>> deque = new LinkedList<>(interfaces);
-            Set<Class<?>> visited = new HashSet<>();
-            while (!deque.isEmpty()) {
-                Class<?> c = deque.poll();
-                if (!visited.add(c)) {
-                    continue;
-                }
+            // set up proxy class access to proxy interfaces and types
+            // referenced in the method signature
+            Set<Class<?>> types = new HashSet<>(interfaces);
+            types.addAll(refTypes);
+            for (Class<?> c : types) {
                 ensureAccess(target, c);
-
-                // add all superinterfaces
-                for (Class<?> intf : c.getInterfaces()) {
-                    deque.add(intf);
-                }
             }
-
-            // set up proxy class access to types referenced in the method signature
-            refTypes.stream()
-                    .filter(t -> !visited.contains(t))
-                    .forEach(t -> ensureAccess(target, t));
             return target;
         }