org.apache.harmony.kernel.vm.Objects Class Reference

List of all members.


Detailed Description

This class must be implemented by the VM to support Object manipulation.

Public Member Functions

long getFieldOffset (Field field)
int getArrayBaseOffset (Class<?> clazz)
int getArrayIndexScale (Class<?> clazz)
boolean compareAndSwapInt (Object object, long fieldOffset, int expected, int update)
boolean compareAndSwapLong (Object object, long fieldOffset, long expected, long update)
boolean compareAndSwapObject (Object object, long fieldOffset, Object expected, Object update)
void putIntVolatile (Object object, long fieldOffset, int newValue)
int getIntVolatile (Object object, long fieldOffset)
void putLongVolatile (Object object, long fieldOffset, long newValue)
long getLongVolatile (Object object, long fieldOffset)
void putObjectVolatile (Object object, long fieldOffset, Object newValue)
Object getObjectVolatile (Object object, long fieldOffset)
void putLong (Object object, long fieldOffset, long newValue)
long getLong (Object object, long fieldOffset)

Static Public Member Functions

static Objects getInstance ()

Static Private Attributes

static final Objects INSTANCE = new Objects()

Member Function Documentation

static Objects org.apache.harmony.kernel.vm.Objects.getInstance (  )  [static]

Retrieves an instance of the Objects service.

Returns:
An instance of Objects.

long org.apache.harmony.kernel.vm.Objects.getFieldOffset ( Field  field  ) 

Retrieves the offset value of the Field for use by other methods in this class.

Parameters:
field The Field to retrieve the offset for.
Returns:
The offset value.

int org.apache.harmony.kernel.vm.Objects.getArrayBaseOffset ( Class<?>  clazz  ) 

Retrieves the base offset for the array Class given. The Class passed MUST me an array type, such that the method Class#isArray() returns true. For example, int[].class.

Parameters:
clazz The array Class object.
Returns:
The base offset value.
Exceptions:
NullPointerException if clazz is null.
IllegalArgumentException if clazz is not an array type.

int org.apache.harmony.kernel.vm.Objects.getArrayIndexScale ( Class<?>  clazz  ) 

Retrieves the array index scale for the array Class given. The index scale is the value used to determine the offset of a particular element in the array given the array's base offset and an index. The following code snippet illustrates the usage.

 int base = Objects.getArrayBaseOffset(int[].class);

 int scale = Objects.getArrayIndexScale(int[].class);

 int elementIdx = 1;

 int[] array = { 0, 1, 2 };

 long offsetForIdx = base + (elementIdx * scale);
 

The Class passed MUST me an array type, such that the method Class#isArray() returns true. For example, int[].class.

Parameters:
clazz The array Class object.
Returns:
The index scale value.
Exceptions:
NullPointerException if clazz is null.
IllegalArgumentException if clazz is not an array type.

boolean org.apache.harmony.kernel.vm.Objects.compareAndSwapInt ( Object  object,
long  fieldOffset,
int  expected,
int  update 
)

Compares and swaps the value of an int-typed field on an Object instance.

Parameters:
object The instance containing the field.
fieldOffset The offset value of the field.
expected The expected value of the field.
update The new value to write to the field.
Returns:
true if the field was updated, false otherwise.

boolean org.apache.harmony.kernel.vm.Objects.compareAndSwapLong ( Object  object,
long  fieldOffset,
long  expected,
long  update 
)

Compares and swaps the value of a long-typed field on an Object instance.

Parameters:
object The instance containing the field.
fieldOffset The offset value of the field.
expected The expected value of the field.
update The new value to write to the field.
Returns:
true if the field was updated, false otherwise.

boolean org.apache.harmony.kernel.vm.Objects.compareAndSwapObject ( Object  object,
long  fieldOffset,
Object  expected,
Object  update 
)

Compares and swaps the value of an Object-typed field on an Object instance.

Parameters:
object The instance containing the field.
fieldOffset The offset value of the field.
expected The expected value of the field.
update The new value to write to the field.
Returns:
true if the field was updated, false otherwise.

void org.apache.harmony.kernel.vm.Objects.putIntVolatile ( Object  object,
long  fieldOffset,
int  newValue 
)

Writes an int value to an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to write to.
fieldOffset The offset of the field to write to.
newValue The value to write.

int org.apache.harmony.kernel.vm.Objects.getIntVolatile ( Object  object,
long  fieldOffset 
)

Reads an int value from an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to read from.
fieldOffset The offset of the field to read from.
Returns:
The value that was read.

void org.apache.harmony.kernel.vm.Objects.putLongVolatile ( Object  object,
long  fieldOffset,
long  newValue 
)

Writes a long value to an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to write to.
fieldOffset The offset of the field to write to.
newValue The value to write.

long org.apache.harmony.kernel.vm.Objects.getLongVolatile ( Object  object,
long  fieldOffset 
)

Reads a long value from an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to read from.
fieldOffset The offset of the field to read from.
Returns:
The value that was read.

void org.apache.harmony.kernel.vm.Objects.putObjectVolatile ( Object  object,
long  fieldOffset,
Object  newValue 
)

Writes an Object reference value to an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to write to.
fieldOffset The offset of the field to write to.
newValue The value to write.

Object org.apache.harmony.kernel.vm.Objects.getObjectVolatile ( Object  object,
long  fieldOffset 
)

Writes an int value to an Object's field as though it were declared volatile.

Parameters:
object The instance containing the field to write to.
fieldOffset The offset of the field to write to.
newValue The value to write.

void org.apache.harmony.kernel.vm.Objects.putLong ( Object  object,
long  fieldOffset,
long  newValue 
)

Writes a long value to an Object's field.

Parameters:
object The instance containing the field to write to.
fieldOffset The offset of the field to write to.
newValue The value to write.

long org.apache.harmony.kernel.vm.Objects.getLong ( Object  object,
long  fieldOffset 
)

Reads a long value from an Object's field.

Parameters:
object The instance containing the field to read from.
fieldOffset The offset of the field to read from.
Returns:
The value that was read.


The documentation for this class was generated from the following file:

Genereated on Tue Dec 9 14:09:48 2008 by Doxygen.

(c) Copyright 2005, 2008 The Apache Software Foundation or its licensors, as applicable.