Logo Search packages:      
Sourcecode: jamvm version File versions

void java::lang::reflect::Field::set ( Object  o,
Object  value 
) throws IllegalAccessException [inline]

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).

If the field is static, o will be ignored. Otherwise, if o is null, you get a NullPointerException, and if it is incompatible with the declaring class of the field, you get an IllegalArgumentException.

Next, if this Field enforces access control, your runtime context is evaluated, and you may have an IllegalAccessException 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 IllegalArgumentException; likewise, this error happens if value 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 ExceptionInInitializerError.

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.

o the object to set this Field on
value the value to set this Field to
IllegalAccessException if you could not normally access this field (i.e. it is not public)
IllegalArgumentException if value cannot be converted by a widening conversion to the underlying type of the Field, or if o is not an instance of the class declaring this field
NullPointerException if o is null and this field requires an instance
ExceptionInInitializerError if accessing a static field triggered class initialization, which then failed
See also:
setBoolean(Object, boolean)

setByte(Object, byte)

setChar(Object, char)

setShort(Object, short)

setInt(Object, int)

setLong(Object, long)

setFloat(Object, float)

setDouble(Object, double)

Definition at line 459 of file Field.java.

    setField(o, declaringClass, type, slot, value);

Generated by  Doxygen 1.6.0   Back to index