8035788: Provide more consistency for lookups
authortwisti
Mon, 14 Jul 2014 13:57:44 +0400
changeset 25537 087de200d457
parent 25536 a1ba79d447e0
child 25538 421c18d84c71
8035788: Provide more consistency for lookups Reviewed-by: jrose, vlivanov, ahgross
jdk/src/share/classes/java/lang/invoke/MethodHandles.java
--- a/jdk/src/share/classes/java/lang/invoke/MethodHandles.java	Thu Mar 13 11:49:24 2014 +0400
+++ b/jdk/src/share/classes/java/lang/invoke/MethodHandles.java	Mon Jul 14 13:57:44 2014 +0400
@@ -1505,6 +1505,10 @@
                 // that is *not* the bytecode behavior.
                 mods ^= Modifier.PROTECTED | Modifier.PUBLIC;
             }
+            if (Modifier.isProtected(mods) && refKind == REF_newInvokeSpecial) {
+                // cannot "new" a protected ctor in a different package
+                mods ^= Modifier.PROTECTED;
+            }
             if (Modifier.isFinal(mods) &&
                     MethodHandleNatives.refKindIsSetter(refKind))
                 throw m.makeAccessException("unexpected set of a final field", this);