changeset 9783:b7dbcd0f7373

8035788: Provide more consistency for lookups Reviewed-by: jrose, vlivanov, ahgross
author twisti
date Wed, 19 Mar 2014 10:51:54 -0700
parents 8503e06e630b
children ab2f56c1f862
files src/share/classes/java/lang/invoke/MethodHandles.java
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/invoke/MethodHandles.java	Thu Mar 13 14:23:21 2014 +0400
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java	Wed Mar 19 10:51:54 2014 -0700
@@ -39,7 +39,9 @@
 import sun.security.util.SecurityConstants;
 import static java.lang.invoke.MethodHandleStatics.*;
 import static java.lang.invoke.MethodHandleNatives.Constants.*;
+
 import java.util.concurrent.ConcurrentHashMap;
+
 import sun.security.util.SecurityConstants;
 
 /**
@@ -1504,6 +1506,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);