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


Java Reflection.quickCheckMemberAccess方法代码示例

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


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

示例1: invoke

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Invokes the underlying method represented by this {@code Method}
 * object, on the specified object with the specified parameters.
 * Individual parameters are automatically unwrapped to match
 * primitive formal parameters, and both primitive and reference
 * parameters are subject to method invocation conversions as
 * necessary.
 *
 * <p>If the underlying method is static, then the specified {@code obj}
 * argument is ignored. It may be null.
 *
 * <p>If the number of formal parameters required by the underlying method is
 * 0, the supplied {@code args} array may be of length 0 or null.
 *
 * <p>If the underlying method is an instance method, it is invoked
 * using dynamic method lookup as documented in The Java Language
 * Specification, Second Edition, section 15.12.4.4; in particular,
 * overriding based on the runtime type of the target object will occur.
 *
 * <p>If the underlying method is static, the class that declared
 * the method is initialized if it has not already been initialized.
 *
 * <p>If the method completes normally, the value it returns is
 * returned to the caller of invoke; if the value has a primitive
 * type, it is first appropriately wrapped in an object. However,
 * if the value has the type of an array of a primitive type, the
 * elements of the array are <i>not</i> wrapped in objects; in
 * other words, an array of primitive type is returned.  If the
 * underlying method return type is void, the invocation returns
 * null.
 *
 * @param obj  the object the underlying method is invoked from
 * @param args the arguments used for the method call
 * @return the result of dispatching the method represented by
 * this object on {@code obj} with parameters
 * {@code args}
 *
 * @exception IllegalAccessException    if this {@code Method} object
 *              is enforcing Java language access control and the underlying
 *              method is inaccessible.
 * @exception IllegalArgumentException  if the method is an
 *              instance method and the specified object argument
 *              is not an instance of the class or interface
 *              declaring the underlying method (or of a subclass
 *              or implementor thereof); if the number of actual
 *              and formal parameters differ; if an unwrapping
 *              conversion for primitive arguments fails; or if,
 *              after possible unwrapping, a parameter value
 *              cannot be converted to the corresponding formal
 *              parameter type by a method invocation conversion.
 * @exception InvocationTargetException if the underlying method
 *              throws an exception.
 * @exception NullPointerException      if the specified object is null
 *              and the method is an instance method.
 * @exception ExceptionInInitializerError if the initialization
 * provoked by this method fails.
 */
@CallerSensitive
public Object invoke(Object obj, Object... args)
    throws IllegalAccessException, IllegalArgumentException,
       InvocationTargetException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    MethodAccessor ma = methodAccessor;             // read volatile
    if (ma == null) {
        ma = acquireMethodAccessor();
    }
    return ma.invoke(obj, args);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:75,代码来源:Method.java

示例2: invoke

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Invokes the underlying method represented by this {@code Method}
 * object, on the specified object with the specified parameters.
 * Individual parameters are automatically unwrapped to match
 * primitive formal parameters, and both primitive and reference
 * parameters are subject to method invocation conversions as
 * necessary.
 *
 * <p>If the underlying method is static, then the specified {@code obj}
 * argument is ignored. It may be null.
 *
 * <p>If the number of formal parameters required by the underlying method is
 * 0, the supplied {@code args} array may be of length 0 or null.
 *
 * <p>If the underlying method is an instance method, it is invoked
 * using dynamic method lookup as documented in The Java Language
 * Specification, Second Edition, section 15.12.4.4; in particular,
 * overriding based on the runtime type of the target object will occur.
 *
 * <p>If the underlying method is static, the class that declared
 * the method is initialized if it has not already been initialized.
 *
 * <p>If the method completes normally, the value it returns is
 * returned to the caller of invoke; if the value has a primitive
 * type, it is first appropriately wrapped in an object. However,
 * if the value has the type of an array of a primitive type, the
 * elements of the array are <i>not</i> wrapped in objects; in
 * other words, an array of primitive type is returned.  If the
 * underlying method return type is void, the invocation returns
 * null.
 *
 * @param obj  the object the underlying method is invoked from
 * @param args the arguments used for the method call
 * @return the result of dispatching the method represented by
 * this object on {@code obj} with parameters
 * {@code args}
 *
 * @exception IllegalAccessException    if this {@code Method} object
 *              is enforcing Java language access control and the underlying
 *              method is inaccessible.
 * @exception IllegalArgumentException  if the method is an
 *              instance method and the specified object argument
 *              is not an instance of the class or interface
 *              declaring the underlying method (or of a subclass
 *              or implementor thereof); if the number of actual
 *              and formal parameters differ; if an unwrapping
 *              conversion for primitive arguments fails; or if,
 *              after possible unwrapping, a parameter value
 *              cannot be converted to the corresponding formal
 *              parameter type by a method invocation conversion.
 * @exception InvocationTargetException if the underlying method
 *              throws an exception.
 * @exception NullPointerException      if the specified object is null
 *              and the method is an instance method.
 * @exception ExceptionInInitializerError if the initialization
 * provoked by this method fails.
 */
@CallerSensitive
public Object invoke(Object obj, Object... args)
    throws IllegalAccessException, IllegalArgumentException,
       InvocationTargetException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    MethodAccessor ma = methodAccessor;             // read volatile
    if (ma == null) {
        ma = acquireMethodAccessor();
    }
    return ma.invoke(obj, args, ikvm.internal.CallerID.getCallerID());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:75,代码来源:Method.java

示例3: newInstance

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Uses the constructor represented by this {@code Constructor} object to
 * create and initialize a new instance of the constructor's
 * declaring class, with the specified initialization parameters.
 * Individual parameters are automatically unwrapped to match
 * primitive formal parameters, and both primitive and reference
 * parameters are subject to method invocation conversions as necessary.
 *
 * <p>If the number of formal parameters required by the underlying constructor
 * is 0, the supplied {@code initargs} array may be of length 0 or null.
 *
 * <p>If the constructor's declaring class is an inner class in a
 * non-static context, the first argument to the constructor needs
 * to be the enclosing instance; see section 15.9.3 of
 * <cite>The Java&trade; Language Specification</cite>.
 *
 * <p>If the required access and argument checks succeed and the
 * instantiation will proceed, the constructor's declaring class
 * is initialized if it has not already been initialized.
 *
 * <p>If the constructor completes normally, returns the newly
 * created and initialized instance.
 *
 * @param initargs array of objects to be passed as arguments to
 * the constructor call; values of primitive types are wrapped in
 * a wrapper object of the appropriate type (e.g. a {@code float}
 * in a {@link java.lang.Float Float})
 *
 * @return a new object created by calling the constructor
 * this object represents
 *
 * @exception IllegalAccessException    if this {@code Constructor} object
 *              is enforcing Java language access control and the underlying
 *              constructor is inaccessible.
 * @exception IllegalArgumentException  if the number of actual
 *              and formal parameters differ; if an unwrapping
 *              conversion for primitive arguments fails; or if,
 *              after possible unwrapping, a parameter value
 *              cannot be converted to the corresponding formal
 *              parameter type by a method invocation conversion; if
 *              this constructor pertains to an enum type.
 * @exception InstantiationException    if the class that declares the
 *              underlying constructor represents an abstract class.
 * @exception InvocationTargetException if the underlying constructor
 *              throws an exception.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 */
@CallerSensitive
public T newInstance(Object ... initargs)
    throws InstantiationException, IllegalAccessException,
           IllegalArgumentException, InvocationTargetException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, null, modifiers);
        }
    }
    if ((clazz.getModifiers() & Modifier.ENUM) != 0)
        throw new IllegalArgumentException("Cannot reflectively create enum objects");
    ConstructorAccessor ca = constructorAccessor;   // read volatile
    if (ca == null) {
        ca = acquireConstructorAccessor();
    }
    @SuppressWarnings("unchecked")
    T inst = (T) ca.newInstance(initargs);
    return inst;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:70,代码来源:Constructor.java

示例4: getLong

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Gets the value of a static or instance field of type
 * {@code long} or of another primitive type convertible to
 * type {@code long} via a widening conversion.
 *
 * @param obj the object to extract the {@code long} value
 * from
 * @return the value of the field converted to type {@code long}
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is inaccessible.
 * @exception IllegalArgumentException  if the specified object is not
 *              an instance of the class or interface declaring the
 *              underlying field (or a subclass or implementor
 *              thereof), or if the field value cannot be
 *              converted to the type {@code long} by a
 *              widening conversion.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#get
 */
@CallerSensitive
public long getLong(Object obj)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    return getFieldAccessor(obj).getLong(obj);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:Field.java

示例5: setFloat

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code float} on the specified object.
 * This method is equivalent to
 * {@code set(obj, fObj)},
 * where {@code fObj} is a {@code Float} object and
 * {@code fObj.floatValue() == f}.
 *
 * @param obj the object whose field should be modified
 * @param f   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setFloat(Object obj, float f)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setFloat(obj, f);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Field.java

示例6: getFloat

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Gets the value of a static or instance field of type
 * {@code float} or of another primitive type convertible to
 * type {@code float} via a widening conversion.
 *
 * @param obj the object to extract the {@code float} value
 * from
 * @return the value of the field converted to type {@code float}
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is inaccessible.
 * @exception IllegalArgumentException  if the specified object is not
 *              an instance of the class or interface declaring the
 *              underlying field (or a subclass or implementor
 *              thereof), or if the field value cannot be
 *              converted to the type {@code float} by a
 *              widening conversion.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see Field#get
 */
@CallerSensitive
public float getFloat(Object obj)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    return getFieldAccessor(obj).getFloat(obj);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:Field.java

示例7: setLong

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code long} on the specified object.
 * This method is equivalent to
 * {@code set(obj, lObj)},
 * where {@code lObj} is a {@code Long} object and
 * {@code lObj.longValue() == l}.
 *
 * @param obj the object whose field should be modified
 * @param l   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setLong(Object obj, long l)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setLong(obj, l);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:Field.java

示例8: setDouble

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code double} on the specified object.
 * This method is equivalent to
 * {@code set(obj, dObj)},
 * where {@code dObj} is a {@code Double} object and
 * {@code dObj.doubleValue() == d}.
 *
 * @param obj the object whose field should be modified
 * @param d   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setDouble(Object obj, double d)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setDouble(obj, d);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:Field.java

示例9: get

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Returns the value of the field represented by this {@code Field}, on
 * the specified object. The value is automatically wrapped in an
 * object if it has a primitive type.
 *
 * <p>The underlying field's value is obtained as follows:
 *
 * <p>If the underlying field is a static field, the {@code obj} argument
 * is ignored; it may be null.
 *
 * <p>Otherwise, the underlying field is an instance field.  If the
 * specified {@code obj} argument is null, the method throws a
 * {@code NullPointerException}. If the specified object is not an
 * instance of the class or interface declaring the underlying
 * field, the method throws an {@code IllegalArgumentException}.
 *
 * <p>If this {@code Field} object is enforcing Java language access control, and
 * the underlying field is inaccessible, the method throws an
 * {@code IllegalAccessException}.
 * If the underlying field is static, the class that declared the
 * field is initialized if it has not already been initialized.
 *
 * <p>Otherwise, the value is retrieved from the underlying instance
 * or static field.  If the field has a primitive type, the value
 * is wrapped in an object before being returned, otherwise it is
 * returned as is.
 *
 * <p>If the field is hidden in the type of {@code obj},
 * the field's value is obtained according to the preceding rules.
 *
 * @param obj object from which the represented field's value is
 * to be extracted
 * @return the value of the represented field in object
 * {@code obj}; primitive values are wrapped in an appropriate
 * object before being returned
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is inaccessible.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof).
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 */
@CallerSensitive
public Object get(Object obj)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    return getFieldAccessor(obj).get(obj);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:60,代码来源:Field.java

示例10: getInt

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Gets the value of a static or instance field of type
 * {@code int} or of another primitive type convertible to
 * type {@code int} via a widening conversion.
 *
 * @param obj the object to extract the {@code int} value
 * from
 * @return the value of the field converted to type {@code int}
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is inaccessible.
 * @exception IllegalArgumentException  if the specified object is not
 *              an instance of the class or interface declaring the
 *              underlying field (or a subclass or implementor
 *              thereof), or if the field value cannot be
 *              converted to the type {@code int} by a
 *              widening conversion.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#get
 */
@CallerSensitive
public int getInt(Object obj)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    return getFieldAccessor(obj).getInt(obj);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Field.java

示例11: set

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the field represented by this {@code Field} object on the
 * specified object argument to the specified new value. The new
 * value is automatically unwrapped if the underlying field has a
 * primitive type.
 *
 * <p>The operation proceeds as follows:
 *
 * <p>If the underlying field is static, the {@code obj} argument is
 * ignored; it may be null.
 *
 * <p>Otherwise the underlying field is an instance field.  If the
 * specified object argument is null, the method throws a
 * {@code NullPointerException}.  If the specified object argument is not
 * an instance of the class or interface declaring the underlying
 * field, the method throws an {@code IllegalArgumentException}.
 *
 * <p>If this {@code Field} object is enforcing Java language access control, and
 * the underlying field is inaccessible, the method throws an
 * {@code IllegalAccessException}.
 *
 * <p>If the underlying field is final, the method throws an
 * {@code IllegalAccessException} unless {@code setAccessible(true)}
 * has succeeded for this {@code Field} object
 * and the field is non-static. Setting a final field in this way
 * is meaningful only during deserialization or reconstruction of
 * instances of classes with blank final fields, before they are
 * made available for access by other parts of a program. Use in
 * any other context may have unpredictable effects, including cases
 * in which other parts of a program continue to use the original
 * value of this field.
 *
 * <p>If the underlying field is of a primitive type, an unwrapping
 * conversion is attempted to convert the new value to a value of
 * a primitive type.  If this attempt fails, the method throws an
 * {@code IllegalArgumentException}.
 *
 * <p>If, after possible unwrapping, the new value cannot be
 * converted to the type of the underlying field by an identity or
 * widening conversion, the method throws an
 * {@code IllegalArgumentException}.
 *
 * <p>If the underlying field is static, the class that declared the
 * field is initialized if it has not already been initialized.
 *
 * <p>The field is set to the possibly unwrapped and widened new value.
 *
 * <p>If the field is hidden in the type of {@code obj},
 * the field's value is set according to the preceding rules.
 *
 * @param obj the object whose field should be modified
 * @param value the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 */
@CallerSensitive
public void set(Object obj, Object value)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).set(obj, value);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:79,代码来源:Field.java

示例12: getBoolean

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Gets the value of a static or instance {@code boolean} field.
 *
 * @param obj the object to extract the {@code boolean} value
 * from
 * @return the value of the {@code boolean} field
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is inaccessible.
 * @exception IllegalArgumentException  if the specified object is not
 *              an instance of the class or interface declaring the
 *              underlying field (or a subclass or implementor
 *              thereof), or if the field value cannot be
 *              converted to the type {@code boolean} by a
 *              widening conversion.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#get
 */
@CallerSensitive
public boolean getBoolean(Object obj)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    return getFieldAccessor(obj).getBoolean(obj);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:35,代码来源:Field.java

示例13: setChar

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code char} on the specified object.
 * This method is equivalent to
 * {@code set(obj, cObj)},
 * where {@code cObj} is a {@code Character} object and
 * {@code cObj.charValue() == c}.
 *
 * @param obj the object whose field should be modified
 * @param c   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setChar(Object obj, char c)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setChar(obj, c);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Field.java

示例14: setShort

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code short} on the specified object.
 * This method is equivalent to
 * {@code set(obj, sObj)},
 * where {@code sObj} is a {@code Short} object and
 * {@code sObj.shortValue() == s}.
 *
 * @param obj the object whose field should be modified
 * @param s   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setShort(Object obj, short s)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setShort(obj, s);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:37,代码来源:Field.java

示例15: setByte

import sun.reflect.Reflection; //导入方法依赖的package包/类
/**
 * Sets the value of a field as a {@code byte} on the specified object.
 * This method is equivalent to
 * {@code set(obj, bObj)},
 * where {@code bObj} is a {@code Byte} object and
 * {@code bObj.byteValue() == b}.
 *
 * @param obj the object whose field should be modified
 * @param b   the new value for the field of {@code obj}
 * being modified
 *
 * @exception IllegalAccessException    if this {@code Field} object
 *              is enforcing Java language access control and the underlying
 *              field is either inaccessible or final.
 * @exception IllegalArgumentException  if the specified object is not an
 *              instance of the class or interface declaring the underlying
 *              field (or a subclass or implementor thereof),
 *              or if an unwrapping conversion fails.
 * @exception NullPointerException      if the specified object is null
 *              and the field is an instance field.
 * @exception ExceptionInInitializerError if the initialization provoked
 *              by this method fails.
 * @see       Field#set
 */
@CallerSensitive
public void setByte(Object obj, byte b)
    throws IllegalArgumentException, IllegalAccessException
{
    if (!override) {
        if (!Reflection.quickCheckMemberAccess(clazz, modifiers)) {
            Class<?> caller = Reflection.getCallerClass();
            checkAccess(caller, clazz, obj, modifiers);
        }
    }
    getFieldAccessor(obj).setByte(obj, b);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:37,代码来源:Field.java


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