Top Description Fields Constructors Methods
org.jboss.marshalling

public final Class FieldSetter

extends Object
Class Inheritance
Static Imports
java.lang.System.getSecurityManager, java.security.AccessController.doPrivileged

A setter for a (possibly final) field, which allows for correct object initialization of java.io.Serializable objects with readObject() methods, even in the presence of final fields.

Field Summary

Modifier and TypeField and Description
private final Class<?>
private final long
private final Class<?>
pack-priv static final Unsafe

Constructor Summary

AccessConstructor and Description
private
FieldSetter(final Field field)

Method Summary

Modifier and TypeMethod and Description
public static FieldSetter

Returns:

the Field instance
get
(final Class<?>
the class containing the field
clazz
,
final String
the name of the field
name
)

Get an instance for the current class.

private static IllegalArgumentException
private static IllegalArgumentException
public void
set(Object
the instance to set
instance
,
Object
the new value
value
)

Set the value of the field to the given object.

public void
setBoolean(Object
the instance to set
instance
,
boolean
the new value
value
)

Set the value of the field to the given value.

public void
setByte(Object
the instance to set
instance
,
byte
the new value
value
)

Set the value of the field to the given value.

public void
setChar(Object
the instance to set
instance
,
char
the new value
value
)

Set the value of the field to the given value.

public void
setDouble(Object
the instance to set
instance
,
double
the new value
value
)

Set the value of the field to the given value.

public void
setFloat(Object
the instance to set
instance
,
float
the new value
value
)

Set the value of the field to the given value.

public void
setInt(Object
the instance to set
instance
,
int
the new value
value
)

Set the value of the field to the given value.

public void
setLong(Object
the instance to set
instance
,
long
the new value
value
)

Set the value of the field to the given value.

public void
setShort(Object
the instance to set
instance
,
short
the new value
value
)

Set the value of the field to the given value.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clazzback to summary
private final Class<?> clazz
fieldOffsetback to summary
private final long fieldOffset
fieldTypeback to summary
private final Class<?> fieldType
unsafeback to summary
pack-priv static final Unsafe unsafe

Constructor Detail

FieldSetterback to summary
private FieldSetter(final Field field)

Method Detail

getback to summary
public static FieldSetter get(final Class<?> clazz, final String name) throws SecurityException, IllegalArgumentException

Get an instance for the current class.

Parameters
clazz:Class<?>

the class containing the field

name:String

the name of the field

Returns:FieldSetter

the Field instance

Exceptions
SecurityException:
if the field does not belong to the caller's class, or the field is static
IllegalArgumentException:
if there is no field of the given name on the given class
incorrectTypeback to summary
private static IllegalArgumentException incorrectType()
incorrectValueTypeback to summary
private static IllegalArgumentException incorrectValueType()
setback to summary
public void set(Object instance, Object value) throws IllegalArgumentException

Set the value of the field to the given object.

Parameters
instance:Object

the instance to set

value:Object

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setBooleanback to summary
public void setBoolean(Object instance, boolean value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:boolean

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setByteback to summary
public void setByte(Object instance, byte value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:byte

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setCharback to summary
public void setChar(Object instance, char value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:char

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setDoubleback to summary
public void setDouble(Object instance, double value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:double

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setFloatback to summary
public void setFloat(Object instance, float value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:float

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setIntback to summary
public void setInt(Object instance, int value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:int

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setLongback to summary
public void setLong(Object instance, long value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:long

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class
setShortback to summary
public void setShort(Object instance, short value) throws IllegalArgumentException

Set the value of the field to the given value.

Parameters
instance:Object

the instance to set

value:short

the new value

Exceptions
IllegalArgumentException:
if the given instance is null or not of the correct class