📄 field.java
字号:
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a byte, short, char, or
* int field of <code>o</code>, or if <code>o</code> is not an
* instance of the declaring class of this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #get(Object)
*/
public int getInt(Object o) throws IllegalAccessException {
return VmReflection.getInt(vmField, o);
}
/**
* Get the value of this Field as a long. If the field is static,
* <code>o</code> will be ignored.
*
* @param o the object to get the value of this Field from
* @return the value of the Field
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a byte, short, char, int,
* or long field of <code>o</code>, or if <code>o</code> is not an
* instance of the declaring class of this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #get(Object)
*/
public long getLong(Object o) throws IllegalAccessException {
return VmReflection.getLong(vmField, o);
}
/**
* Get the value of this Field as a float. If the field is static,
* <code>o</code> will be ignored.
*
* @param o the object to get the value of this Field from
* @return the value of the Field
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a byte, short, char, int,
* long, or float field of <code>o</code>, or if <code>o</code> is
* not an instance of the declaring class of this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #get(Object)
*/
public float getFloat(Object o) throws IllegalAccessException {
return VmReflection.getFloat(vmField, o);
}
/**
* Get the value of this Field as a double. If the field is static,
* <code>o</code> will be ignored.
*
* @param o the object to get the value of this Field from
* @return the value of the Field
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a byte, short, char, int,
* long, float, or double field of <code>o</code>, or if
* <code>o</code> is not an instance of the declaring class of this
* field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #get(Object)
*/
public double getDouble(Object o) throws IllegalAccessException {
return VmReflection.getDouble(vmField, o);
}
/**
* Set the value of this Field. If it is a primitive field, the value
* will be unwrapped from the passed object (boolean = java.lang.Boolean).<p>
*
* If the field is static, <code>o</code> will be ignored. Otherwise, if
* <code>o</code> is null, you get a <code>NullPointerException</code>,
* and if it is incompatible with the declaring class of the field, you
* get an <code>IllegalArgumentException</code>.<p>
*
* Next, if this Field enforces access control, your runtime context is
* evaluated, and you may have an <code>IllegalAccessException</code> if
* you could not access this field in similar compiled code. This also
* occurs whether or not there is access control if the field is final.
* If the field is primitive, and unwrapping your argument fails, you will
* get an <code>IllegalArgumentException</code>; likewise, this error
* happens if <code>value</code> cannot be cast to the correct object type.
* If the field is static, and its class is uninitialized, you trigger class
* initialization, which may end in a
* <code>ExceptionInInitializerError</code>.<p>
*
* Finally, the field is set with the widened value. This method accesses
* the field of the declaring class, even if the instance passed in belongs
* to a subclass which declares another field to hide this one.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if <code>value</code> cannot be
* converted by a widening conversion to the underlying type of
* the Field, or if <code>o</code> is not an instance of the class
* declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #setBoolean(Object, boolean)
* @see #setByte(Object, byte)
* @see #setChar(Object, char)
* @see #setShort(Object, short)
* @see #setInt(Object, int)
* @see #setLong(Object, long)
* @see #setFloat(Object, float)
* @see #setDouble(Object, double)
*/
public void set(Object o, Object value) throws IllegalAccessException {
VmReflection.setObject(vmField, o, value);
}
/**
* Set this boolean Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a boolean field, or if
* <code>o</code> is not an instance of the class declaring this
* field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setBoolean(Object o, boolean value) throws IllegalAccessException {
VmReflection.setBoolean(vmField, o, value);
}
/**
* Set this byte Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a byte, short, int, long,
* float, or double field, or if <code>o</code> is not an instance
* of the class declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setByte(Object o, byte value) throws IllegalAccessException {
VmReflection.setByte(vmField, o, value);
}
/**
* Set this char Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a char, int, long,
* float, or double field, or if <code>o</code> is not an instance
* of the class declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setChar(Object o, char value) throws IllegalAccessException {
VmReflection.setChar(vmField, o, value);
}
/**
* Set this short Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a short, int, long,
* float, or double field, or if <code>o</code> is not an instance
* of the class declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setShort(Object o, short value) throws IllegalAccessException {
VmReflection.setShort(vmField, o, value);
}
/**
* Set this int Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not an int, long, float, or
* double field, or if <code>o</code> is not an instance of the
* class declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setInt(Object o, int value) throws IllegalAccessException {
VmReflection.setInt(vmField, o, value);
}
/**
* Set this long Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a long, float, or double
* field, or if <code>o</code> is not an instance of the class
* declaring this field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setLong(Object o, long value) throws IllegalAccessException {
VmReflection.setLong(vmField, o, value);
}
/**
* Set this float Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a float or long field, or
* if <code>o</code> is not an instance of the class declaring this
* field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setFloat(Object o, float value) throws IllegalAccessException {
VmReflection.setFloat(vmField, o, value);
}
/**
* Set this double Field. If the field is static, <code>o</code> will be
* ignored.
*
* @param o the object to set this Field on
* @param value the value to set this Field to
* @throws IllegalAccessException if you could not normally access this field
* (i.e. it is not public)
* @throws IllegalArgumentException if this is not a double field, or if
* <code>o</code> is not an instance of the class declaring this
* field
* @throws NullPointerException if <code>o</code> is null and this field
* requires an instance
* @throws ExceptionInInitializerError if accessing a static field triggered
* class initialization, which then failed
* @see #set(Object, Object)
*/
public void setDouble(Object o, double value) throws IllegalAccessException {
VmReflection.setDouble(vmField, o, value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -