Field.get

Field.get

Class Overview | Class Members | This Package | All Packages

Syntax
public native Object get( Object obj ) throws IllegalArgumentException, IllegalAccessException
Description
Returns the value of the field represented by this Field, on the specified object. The value is automatically wrapped in an object if it has a primitive type.

The underlying field's value is obtained as follows:

If the underlying field is a static field, the object argument is ignored; it may be null.

Otherwise, the underlying field is an instance field. If the specified object argument is null, the method throws a NullPointerException. If the specified object is not an instance of the class or interface declaring the underlying field, the method throws an IllegalArgumentException.

If this Field object enforces Java language access control, and the underlying field is inaccessible, the method throws an IllegalAccessException.

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.

Exceptions
IllegalAccessException if the underlying constructor is inaccessible.
Exceptions
IllegalArgumentException if the specified object is not an instance of the class or interface declaring the underlying field.
Exceptions
NullPointerException if the specified object is null.