当前位置: 首页>>代码示例>>Java>>正文


Java AccessibleObject.isAccessible方法代码示例

本文整理汇总了Java中java.lang.reflect.AccessibleObject.isAccessible方法的典型用法代码示例。如果您正苦于以下问题:Java AccessibleObject.isAccessible方法的具体用法?Java AccessibleObject.isAccessible怎么用?Java AccessibleObject.isAccessible使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.AccessibleObject的用法示例。


在下文中一共展示了AccessibleObject.isAccessible方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAccessibleWorkaround

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
static boolean setAccessibleWorkaround(final AccessibleObject o) {
    if (o == null || o.isAccessible()) {
        return false;
    }
    final Member m = (Member) o;
    if (!o.isAccessible() && Modifier.isPublic(m.getModifiers()) && isPackageAccess(m
            .getDeclaringClass().getModifiers())) {
        try {
            o.setAccessible(true);
            return true;
        } catch (final SecurityException e) { // NOPMD
            // ignore in favor of subsequent IllegalAccessException
        }
    }
    return false;
}
 
开发者ID:zkwlx,项目名称:DroidTelescope,代码行数:17,代码来源:MemberUtils.java

示例2: tryToMakeAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
@Override
protected boolean tryToMakeAccessible(Object accessibleObject)
{
    if (!(accessibleObject instanceof AccessibleObject)) {
        return false;
    }
    AccessibleObject accessible = (AccessibleObject)accessibleObject;
    if (accessible.isAccessible()) {
        return true;
    }
    try {
        accessible.setAccessible(true);
    } catch (Exception ex) { }

    return accessible.isAccessible();
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:17,代码来源:VMBridge_jdk13.java

示例3: setAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
static void setAccessible(AccessibleObject obj){
    if(!setAccessibleEnable){
        return;
    }
    if(obj.isAccessible()){
        return;
    }
    try{
        obj.setAccessible(true);
    } catch(AccessControlException error){
        setAccessibleEnable = false;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:TypeUtils.java

示例4: tryToMakeAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
@Override
protected boolean tryToMakeAccessible(AccessibleObject accessible)
{
    if (accessible.isAccessible()) {
        return true;
    }
    try {
        accessible.setAccessible(true);
    } catch (Exception ex) { }

    return accessible.isAccessible();
}
 
开发者ID:MikaGuraN,项目名称:HL4A,代码行数:13,代码来源:VMBridge_jdk15.java

示例5: setAccessibleWorkaround

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
/**
 * XXX Default access superclass workaround
 *
 * When a public class has a default access superclass with public members,
 * these members are accessible. Calling them from compiled code works fine.
 * Unfortunately, on some JVMs, using reflection to invoke these members
 * seems to (wrongly) to prevent access even when the modifer is public.
 * Calling setAccessible(true) solves the problem but will only work from
 * sufficiently privileged code. Better workarounds would be gratefully
 * accepted.
 * @param o the AccessibleObject to set as accessible
 */
static void setAccessibleWorkaround(AccessibleObject o) {
    if (o == null || o.isAccessible()) {
        return;
    }
    Member m = (Member) o;
    if (Modifier.isPublic(m.getModifiers())
            && isPackageAccess(m.getDeclaringClass().getModifiers())) {
        try {
            o.setAccessible(true);
        } catch (SecurityException e) {
            // ignore in favor of subsequent IllegalAccessException
        }
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:27,代码来源:MemberUtils.java

示例6: setAccessibleWorkaround

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
static boolean setAccessibleWorkaround(final AccessibleObject o) {
    if (o == null || o.isAccessible()) {
        return false;
    }
    final Member m = (Member) o;
    if (!o.isAccessible() && Modifier.isPublic(m.getModifiers()) && isPackageAccess(m.getDeclaringClass().getModifiers())) {
        try {
            o.setAccessible(true);
            return true;
        } catch (final SecurityException e) { // NOPMD
            // ignore in favor of subsequent IllegalAccessException
        }
    }
    return false;
}
 
开发者ID:amikey,项目名称:DroidPlugin,代码行数:16,代码来源:MemberUtils.java

示例7: setAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
static void setAccessible(AccessibleObject obj) {
    if (setAccessibleEnable && !obj.isAccessible()) {
        try {
            obj.setAccessible(true);
        } catch (AccessControlException e) {
            setAccessibleEnable = false;
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:10,代码来源:TypeUtils.java

示例8: makeAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
protected static void makeAccessible(AccessibleObject object) {
    if (!object.isAccessible()) {
        AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
            object.setAccessible(true);
            return null;
        });
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:9,代码来源:AbstractErrorUnmarshaller.java

示例9: setAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
static void setAccessible(AccessibleObject obj) {
    if (!setAccessibleEnable) {
        return;
    }
    
    if (obj.isAccessible()) {
        return;
    }
    
    try {
        obj.setAccessible(true);
    } catch (AccessControlException error) {
        setAccessibleEnable = false;
    }
}
 
开发者ID:uavorg,项目名称:uavstack,代码行数:16,代码来源:TypeUtils.java

示例10: getDataMutator

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
/** Returns the Field object, if available, or the setter Method, corresponding to the input dataFieldName.
 * @param dataFieldName the name of the data field.
 * @return the Field object, if available, or the setter Method, corresponding to the input dataFieldName.
 */
public AccessibleObject getDataMutator(String dataFieldName) {
    AccessibleObject accessibleObject = containsDataField(dataFieldName) ? elementMap.get(dataFieldName).getGraphField() : null;
    if (accessibleObject == null) {
        PropertyDescriptor pd = getDataFieldDescriptor(dataFieldName);
        if (pd != null) {
            accessibleObject = pd.getWriteMethod();
            if (!accessibleObject.isAccessible())
                accessibleObject.setAccessible(true);
        }
    }
    return accessibleObject;
}
 
开发者ID:jaffa-projects,项目名称:jaffa-framework,代码行数:17,代码来源:GraphMapping.java

示例11: setAccessibleWorkaround

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
/**
 * XXX Default access superclass workaround
 * <p>
 * When a public class has a default access superclass with public members,
 * these members are accessible. Calling them from compiled code works fine.
 * Unfortunately, on some JVMs, using reflection to invoke these members
 * seems to (wrongly) prevent access even when the modifier is public.
 * Calling setAccessible(true) solves the problem but will only work from
 * sufficiently privileged code. Better workarounds would be gratefully
 * accepted.
 *
 * @param o the AccessibleObject to set as accessible
 */
static void setAccessibleWorkaround(AccessibleObject o) {
    if (o == null || o.isAccessible()) {
        return;
    }
    Member m = (Member) o;
    if (Modifier.isPublic(m.getModifiers())
            && isPackageAccess(m.getDeclaringClass().getModifiers())) {
        try {
            o.setAccessible(true);
        } catch (SecurityException e) { // NOPMD
            // ignore in favor of subsequent IllegalAccessException
        }
    }
}
 
开发者ID:rrrfff,项目名称:AndHook,代码行数:28,代码来源:MemberUtils.java

示例12: setAccessible

import java.lang.reflect.AccessibleObject; //导入方法依赖的package包/类
public static void setAccessible(AccessibleObject ao, boolean value) {
    if (ao.isAccessible() != value) {
        ao.setAccessible(value);
    }
}
 
开发者ID:wangyupeng1-iri,项目名称:springreplugin,代码行数:6,代码来源:ReflectUtils.java


注:本文中的java.lang.reflect.AccessibleObject.isAccessible方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。