changeset 48842:28145af98042 nestmates

8197395: [Nestmates] VerifyAccess.isMemberAccessible must not allow private access between legacy nested types Reviewed-by: mchung, acorn
author dholmes
date Sun, 11 Feb 2018 20:26:22 -0500
parents 78e9e31d5c52
children 18b28297b5ed
files src/java.base/share/classes/sun/invoke/util/VerifyAccess.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Thu Feb 08 21:12:21 2018 -0500
+++ b/src/java.base/share/classes/sun/invoke/util/VerifyAccess.java	Sun Feb 11 20:26:22 2018 -0500
@@ -133,12 +133,19 @@
                     isSamePackage(defc, lookupClass));
         case PRIVATE:
             // Rules for privates follows access rules for nestmates.
-            return ((allowedModes & PRIVATE) != 0 &&
-                    areNestMates(defc, lookupClass));
+            boolean canAccess = ((allowedModes & PRIVATE) != 0 &&
+                                 Reflection.areNestMates(defc, lookupClass));
+            // FIX ME: Sanity check refc == defc. Either remove or convert to
+            // plain assert before integration.
+            myassert((canAccess && refc == defc) || !canAccess);
+            return canAccess;
         default:
             throw new IllegalArgumentException("bad modifiers: "+Modifier.toString(mods));
         }
     }
+    static void myassert(boolean cond) {
+        if (!cond) throw new Error("Assertion failed");
+    }
 
     static boolean isRelatedClass(Class<?> refc, Class<?> lookupClass) {
         return (refc == lookupClass ||