1.1 --- a/rt/emul/compact/src/main/java/java/lang/invoke/MethodHandles.java Sat Aug 09 11:11:13 2014 +0200
1.2 +++ b/rt/emul/compact/src/main/java/java/lang/invoke/MethodHandles.java Sun Aug 10 06:13:36 2014 +0200
1.3 @@ -33,14 +33,9 @@
1.4 import sun.invoke.util.ValueConversions;
1.5 import sun.invoke.util.VerifyAccess;
1.6 import sun.invoke.util.Wrapper;
1.7 -import sun.reflect.CallerSensitive;
1.8 -import sun.reflect.Reflection;
1.9 -import sun.reflect.misc.ReflectUtil;
1.10 -import sun.security.util.SecurityConstants;
1.11 import static java.lang.invoke.MethodHandleStatics.*;
1.12 import static java.lang.invoke.MethodHandleNatives.Constants.*;
1.13 import java.util.concurrent.ConcurrentHashMap;
1.14 -import sun.security.util.SecurityConstants;
1.15
1.16 /**
1.17 * This class consists exclusively of static methods that operate on or return
1.18 @@ -85,9 +80,10 @@
1.19 * executing in the same caller class {@code C}.
1.20 * @return a lookup object for the caller of this method, with private access
1.21 */
1.22 - @CallerSensitive
1.23 +// @CallerSensitive
1.24 public static Lookup lookup() {
1.25 - return new Lookup(Reflection.getCallerClass());
1.26 + throw new IllegalStateException("Implement me!");
1.27 +// return new Lookup(Reflection.getCallerClass());
1.28 }
1.29
1.30 /**
1.31 @@ -138,14 +134,14 @@
1.32 */
1.33 public static <T extends Member> T
1.34 reflectAs(Class<T> expected, MethodHandle target) {
1.35 - SecurityManager smgr = System.getSecurityManager();
1.36 - if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION);
1.37 +// SecurityManager smgr = System.getSecurityManager();
1.38 +// if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION);
1.39 Lookup lookup = Lookup.IMPL_LOOKUP; // use maximally privileged lookup
1.40 return lookup.revealDirect(target).reflectAs(expected, lookup);
1.41 }
1.42 // Copied from AccessibleObject, as used by Method.setAccessible, etc.:
1.43 - static final private java.security.Permission ACCESS_PERMISSION =
1.44 - new ReflectPermission("suppressAccessChecks");
1.45 +// static final private java.security.Permission ACCESS_PERMISSION =
1.46 +// new ReflectPermission("suppressAccessChecks");
1.47
1.48 /**
1.49 * A <em>lookup object</em> is a factory for creating method handles,
1.50 @@ -1428,28 +1424,28 @@
1.51 * If this lookup object has private access, then the caller class is the lookupClass.
1.52 */
1.53 void checkSecurityManager(Class<?> refc, MemberName m) {
1.54 - SecurityManager smgr = System.getSecurityManager();
1.55 - if (smgr == null) return;
1.56 - if (allowedModes == TRUSTED) return;
1.57 -
1.58 - // Step 1:
1.59 - boolean fullPowerLookup = hasPrivateAccess();
1.60 - if (!fullPowerLookup ||
1.61 - !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
1.62 - ReflectUtil.checkPackageAccess(refc);
1.63 - }
1.64 -
1.65 - // Step 2:
1.66 - if (m.isPublic()) return;
1.67 - if (!fullPowerLookup) {
1.68 - smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
1.69 - }
1.70 -
1.71 - // Step 3:
1.72 - Class<?> defc = m.getDeclaringClass();
1.73 - if (!fullPowerLookup && defc != refc) {
1.74 - ReflectUtil.checkPackageAccess(defc);
1.75 - }
1.76 +// SecurityManager smgr = System.getSecurityManager();
1.77 +// if (smgr == null) return;
1.78 +// if (allowedModes == TRUSTED) return;
1.79 +//
1.80 +// // Step 1:
1.81 +// boolean fullPowerLookup = hasPrivateAccess();
1.82 +// if (!fullPowerLookup ||
1.83 +// !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
1.84 +// ReflectUtil.checkPackageAccess(refc);
1.85 +// }
1.86 +//
1.87 +// // Step 2:
1.88 +// if (m.isPublic()) return;
1.89 +// if (!fullPowerLookup) {
1.90 +// smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
1.91 +// }
1.92 +//
1.93 +// // Step 3:
1.94 +// Class<?> defc = m.getDeclaringClass();
1.95 +// if (!fullPowerLookup && defc != refc) {
1.96 +// ReflectUtil.checkPackageAccess(defc);
1.97 +// }
1.98 }
1.99
1.100 void checkMethod(byte refKind, Class<?> refc, MemberName m) throws IllegalAccessException {
1.101 @@ -1749,17 +1745,17 @@
1.102 return false;
1.103 }
1.104 ClassLoader loader = defc.getClassLoader();
1.105 - if (!sun.misc.VM.isSystemDomainLoader(loader)) {
1.106 - ClassLoader sysl = ClassLoader.getSystemClassLoader();
1.107 - boolean found = false;
1.108 - while (sysl != null) {
1.109 - if (loader == sysl) { found = true; break; }
1.110 - sysl = sysl.getParent();
1.111 - }
1.112 - if (!found) {
1.113 - return false;
1.114 - }
1.115 - }
1.116 +// if (!sun.misc.VM.isSystemDomainLoader(loader)) {
1.117 +// ClassLoader sysl = ClassLoader.getSystemClassLoader();
1.118 +// boolean found = false;
1.119 +// while (sysl != null) {
1.120 +// if (loader == sysl) { found = true; break; }
1.121 +// sysl = sysl.getParent();
1.122 +// }
1.123 +// if (!found) {
1.124 +// return false;
1.125 +// }
1.126 +// }
1.127 try {
1.128 MemberName resolved2 = publicLookup().resolveOrFail(refKind,
1.129 new MemberName(refKind, defc, member.getName(), member.getType()));