changeset 52859:413c28945e0f

8214795: Add safety check to dynalink inner class lookup Reviewed-by: sundar, attila
author hannesw
date Wed, 05 Dec 2018 19:17:22 +0100
parents dad45affbdaa
children 8dd8965df7f6
files src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java
diffstat 1 files changed, 4 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java	Wed Dec 05 16:11:53 2018 +0100
+++ b/src/jdk.dynalink/share/classes/jdk/dynalink/beans/AccessibleMembersLookup.java	Wed Dec 05 19:17:22 2018 +0100
@@ -216,7 +216,10 @@
                 // were not yet loaded, they'll only get loaded in a non-resolved state; no static initializers for
                 // them will trigger just by doing this.
                 // Don't overwrite an inner class with an inherited inner class with the same name.
-                innerClasses.putIfAbsent(innerClass.getSimpleName(), innerClass);
+                Class<?> previousClass = innerClasses.get(innerClass.getSimpleName());
+                if (previousClass == null || previousClass.getDeclaringClass().isAssignableFrom(innerClass.getDeclaringClass())) {
+                    innerClasses.put(innerClass.getSimpleName(), innerClass);
+                }
             }
         } else {
             searchSuperTypes = true;