當前位置: 首頁>>代碼示例>>Java>>正文


Java Member.PUBLIC屬性代碼示例

本文整理匯總了Java中java.lang.reflect.Member.PUBLIC屬性的典型用法代碼示例。如果您正苦於以下問題:Java Member.PUBLIC屬性的具體用法?Java Member.PUBLIC怎麽用?Java Member.PUBLIC使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在java.lang.reflect.Member的用法示例。


在下文中一共展示了Member.PUBLIC屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkMemberAccess

private void checkMemberAccess(int which, Class<?> caller, boolean checkProxyInterfaces) {
    final SecurityManager s = System.getSecurityManager();
    if (s != null) {
        /* Default policy allows access to all {@link Member#PUBLIC} members,
         * as well as access to classes that have the same class loader as the caller.
         * In all other cases, it requires RuntimePermission("accessDeclaredMembers")
         * permission.
         */
        final ClassLoader ccl = ClassLoader.getClassLoader(caller);
        final ClassLoader cl = getClassLoader0();
        if (which != Member.PUBLIC) {
            if (ccl != cl) {
                s.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
            }
        }
        this.checkPackageAccess(ccl, checkProxyInterfaces);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:18,代碼來源:Class.java

示例2: checkMemberAccess

private void checkMemberAccess(SecurityManager sm, int which,
                               Class<?> caller, boolean checkProxyInterfaces) {
    /* Default policy allows access to all {@link Member#PUBLIC} members,
     * as well as access to classes that have the same class loader as the caller.
     * In all other cases, it requires RuntimePermission("accessDeclaredMembers")
     * permission.
     */
    final ClassLoader ccl = ClassLoader.getClassLoader(caller);
    if (which != Member.PUBLIC) {
        final ClassLoader cl = getClassLoader0();
        if (ccl != cl) {
            sm.checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
        }
    }
    this.checkPackageAccess(sm, ccl, checkProxyInterfaces);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:16,代碼來源:Class.java

示例3: checkMemberAccess

/**
 * Throws a <code>SecurityException</code> if the
 * calling thread is not allowed to access members.
 * <p>
 * The default policy is to allow access to PUBLIC members, as well
 * as access to classes that have the same class loader as the caller.
 * In all other cases, this method calls <code>checkPermission</code>
 * with the <code>RuntimePermission("accessDeclaredMembers")
 * </code> permission.
 * <p>
 * If this method is overridden, then a call to
 * <code>super.checkMemberAccess</code> cannot be made,
 * as the default implementation of <code>checkMemberAccess</code>
 * relies on the code being checked being at a stack depth of
 * 4.
 *
 * @param clazz the class that reflection is to be performed on.
 *
 * @param which type of access, PUBLIC or DECLARED.
 *
 * @exception  SecurityException if the caller does not have
 *             permission to access members.
 * @exception  NullPointerException if the <code>clazz</code> argument is
 *             <code>null</code>.
 *
 * @deprecated This method relies on the caller being at a stack depth
 *             of 4 which is error-prone and cannot be enforced by the runtime.
 *             Users of this method should instead invoke {@link #checkPermission}
 *             directly.
 *             This method is subject to removal in a future version of Java SE.
 *
 * @see java.lang.reflect.Member
 * @since 1.1
 * @see        #checkPermission(java.security.Permission) checkPermission
 */
@Deprecated(since="1.8", forRemoval=true)
@CallerSensitive
public void checkMemberAccess(Class<?> clazz, int which) {
    if (clazz == null) {
        throw new NullPointerException("class can't be null");
    }
    if (which != Member.PUBLIC) {
        Class<?> stack[] = getClassContext();
        /*
         * stack depth of 4 should be the caller of one of the
         * methods in java.lang.Class that invoke checkMember
         * access. The stack should look like:
         *
         * someCaller                        [3]
         * java.lang.Class.someReflectionAPI [2]
         * java.lang.Class.checkMemberAccess [1]
         * SecurityManager.checkMemberAccess [0]
         *
         */
        if ((stack.length<4) ||
            (stack[3].getClassLoader() != clazz.getClassLoader())) {
            checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:60,代碼來源:SecurityManager.java


注:本文中的java.lang.reflect.Member.PUBLIC屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。