java.lang.reflect.Field.checkAccess()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(104)

本文整理了Java中java.lang.reflect.Field.checkAccess()方法的一些代码示例,展示了Field.checkAccess()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Field.checkAccess()方法的具体详情如下:
包路径:java.lang.reflect.Field
类名称:Field
方法名:checkAccess

Field.checkAccess介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code long}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public long getLong(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getLong(object, getType(), Long.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code
 * boolean}. This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public boolean getBoolean(Object object)
    throws IllegalAccessException, IllegalArgumentException {
  
  checkAccess(object, false);
  checkReceiver(object);
  return getBoolean(object, getType(), Boolean.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as an {@code int}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public int getInt(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getInt(object, getType(), Integer.TYPE);
}

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setLong(object, value, getType(), Long.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setBoolean(object, value, getType(), Boolean.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setInt(object, value, getType(), Integer.TYPE);

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code float}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public float getFloat(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getFloat(object, getType(), Float.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code short}
 * . This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public short getShort(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getShort(object, getType(), Short.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code byte}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public byte getByte(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getByte(object, getType(), Byte.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code char}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public char getChar(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getChar(object, getType(), Character.TYPE);
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the value of the field in the specified object as a {@code
 * double}. This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public double getDouble(Object object)
    throws IllegalAccessException, IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getDouble(object, getType(), Double.TYPE);
}

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setByte(object, value, getType(), Byte.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setShort(object, value, getType(), Short.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setChar(object, value, getType(), Character.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setDouble(object, value, getType(), Double.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
setFloat(object, value, getType(), Float.TYPE);

代码示例来源:origin: robovm/robovm

throws IllegalAccessException, IllegalArgumentException {
checkAccess(object, true);
checkReceiver(object);
Class<?> type = getType();

代码示例来源:origin: robovm/robovm

IllegalArgumentException {
checkAccess(object, false);
checkReceiver(object);
Class<?> type = getType();

代码示例来源:origin: MobiVM/robovm

/**
 * Returns the value of the field in the specified object as a {@code char}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public char getChar(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getChar(object, getType(), Character.TYPE);
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns the value of the field in the specified object as a {@code char}.
 * This reproduces the effect of {@code object.fieldName}
 * <p>
 * If this field is static, the object argument is ignored.
 * Otherwise, if the object is {@code null}, a NullPointerException is
 * thrown. If the object is not an instance of the declaring class of the
 * method, an IllegalArgumentException is thrown.
 * <p>
 * If this Field object is enforcing access control (see AccessibleObject)
 * and this field is not accessible from the current context, an
 * IllegalAccessException is thrown.
 *
 * @param object
 *            the object to access
 * @return the field value
 * @throws NullPointerException
 *             if the object is {@code null} and the field is non-static
 * @throws IllegalArgumentException
 *             if the object is not compatible with the declaring class
 * @throws IllegalAccessException
 *             if this field is not accessible
 */
public char getChar(Object object) throws IllegalAccessException,
    IllegalArgumentException {
      
  checkAccess(object, false);
  checkReceiver(object);
  return getChar(object, getType(), Character.TYPE);
}

相关文章

微信公众号

最新文章

更多