Java Code Examples for sun.invoke.util.VerifyAccess#classLoaderIsAncestor()

The following examples show how to use sun.invoke.util.VerifyAccess#classLoaderIsAncestor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodHandles.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 2
Source File: MethodHandles.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 3
Source File: MethodHandles.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 4
Source File: MethodHandles.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 5
Source File: MethodHandles.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 6
Source File: MethodHandles.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 7
Source File: MethodHandles.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 8
Source File: MethodHandles.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 9
Source File: MethodHandles.java    From Java8CN with Apache License 2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 10
Source File: MethodHandles.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 11
Source File: MethodHandles.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 12
Source File: MethodHandles.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 13
Source File: MethodHandles.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 14
Source File: MethodHandles.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}
 
Example 15
Source File: MethodHandles.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Perform necessary <a href="MethodHandles.Lookup.html#secmgr">access checks</a>.
 * Determines a trustable caller class to compare with refc, the symbolic reference class.
 * If this lookup object has private access, then the caller class is the lookupClass.
 */
void checkSecurityManager(Class<?> refc, MemberName m) {
    SecurityManager smgr = System.getSecurityManager();
    if (smgr == null)  return;
    if (allowedModes == TRUSTED)  return;

    // Step 1:
    boolean fullPowerLookup = hasPrivateAccess();
    if (!fullPowerLookup ||
        !VerifyAccess.classLoaderIsAncestor(lookupClass, refc)) {
        ReflectUtil.checkPackageAccess(refc);
    }

    // Step 2:
    if (m.isPublic()) return;
    if (!fullPowerLookup) {
        smgr.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
    }

    // Step 3:
    Class<?> defc = m.getDeclaringClass();
    if (!fullPowerLookup && defc != refc) {
        ReflectUtil.checkPackageAccess(defc);
    }
}