changeset 7305:bac16c82c14a jdk7u65-b04

8035788: Provide more consistency for lookups Reviewed-by: jrose, vlivanov, ahgross
author twisti
date Wed, 19 Mar 2014 10:48:43 -0700
parents f0f5f7e38090
children 9f62204f67ec
files src/share/classes/java/lang/invoke/MethodHandles.java
diffstat 1 files changed, 7 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/lang/invoke/MethodHandles.java	Tue Mar 18 13:10:13 2014 -0700
+++ b/src/share/classes/java/lang/invoke/MethodHandles.java	Wed Mar 19 10:48:43 2014 -0700
@@ -26,12 +26,15 @@
 package java.lang.invoke;
 
 import java.lang.reflect.*;
+
 import sun.invoke.util.ValueConversions;
 import sun.invoke.util.VerifyAccess;
 import sun.invoke.util.Wrapper;
+
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Arrays;
+
 import sun.reflect.CallerSensitive;
 import sun.reflect.Reflection;
 import sun.reflect.misc.ReflectUtil;
@@ -1155,6 +1158,10 @@
             int allowedModes = this.allowedModes;
             if (allowedModes == TRUSTED)  return;
             int mods = m.getModifiers();
+            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);