8214795: Add safety check to dynalink inner class lookup
Reviewed-by: sundar, attila
--- 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;