APIdia Launch Partner
Top Description Fields Methods
com.sun.jdi

public Interface ArrayReference

extends ObjectReference
Known Direct Implementers
com.sun.tools.jdi.ArrayReferenceImpl
Imports
java.util.List

Provides access to an array object and its components in the target VM. Each array component is mirrored by a Value object. The array components, in aggregate, are placed in java.util.List objects instead of arrays for consistency with the rest of the API and for interoperability with other APIs.
Authors
Robert Field, Gordon Hirsch, James McIlree
Since
1.3

Field Summary

Inherited from com.sun.jdi.ObjectReference:
INVOKE_NONVIRTUALINVOKE_SINGLE_THREADED

Method Summary

Modifier and TypeMethod and Description
public Value

Returns:

the Value at the given index.
getValue
(int
the index of the component to retrieve
index
)

Returns an array component value.

public List<Value>

Returns:

a list of Value objects, one for each array component ordered by array index. For zero length arrays, an empty list is returned.
getValues
()

Returns all of the components in this array.

public List<Value>

Returns:

a list of Value objects, one for each requested array component ordered by array index. When there are no elements in the specified range (e.g. length is zero) an empty list is returned
getValues
(int
the index of the first component to retrieve
index
,
int
the number of components to retrieve, or -1 to retrieve all components to the end of this array.
length
)

Returns a range of array components.

public int

Returns:

the integer count of components in this array.
length
()

Returns the number of components in this array.

public void
setValue(int
the index of the component to set
index
,
Value
the new value
value
)

Replaces an array component with another value.

public void
setValues(List<? extends Value>
a list of Value objects to be placed in this array. If values.size() is less that the length of the array, the first values.size() elements are set.
values
)

Replaces all array components with other values.

public void
setValues(int
the index of the first component to set.
index
,
List<? extends Value>
a list of Value objects to be placed in this array.
values
,
int
the index of the first source value to use.
srcIndex
,
int
the number of components to set, or -1 to set all components to the end of this array or the end of values (whichever comes first).
length
)

Replaces a range of array components with other values.

Inherited from com.sun.jdi.ObjectReference:
disableCollectionenableCollectionentryCountequalsgetValuegetValueshashCodeinvokeMethodisCollectedowningThreadreferenceTypereferringObjectssetValueuniqueIDwaitingThreads

Method Detail

getValueback to summary
public Value getValue(int index)

Returns an array component value.

Parameters
index:int

the index of the component to retrieve

Returns:Value

the Value at the given index.

Exceptions
IndexOutOfBoundsException:
if index is outside the range of this array, that is, if either of the following are true:
 index < 0 index >= length() 
getValuesback to summary
public List<Value> getValues()

Returns all of the components in this array.

Returns:List<Value>

a list of Value objects, one for each array component ordered by array index. For zero length arrays, an empty list is returned.

getValuesback to summary
public List<Value> getValues(int index, int length)

Returns a range of array components.

Parameters
index:int

the index of the first component to retrieve

length:int

the number of components to retrieve, or -1 to retrieve all components to the end of this array.

Returns:List<Value>

a list of Value objects, one for each requested array component ordered by array index. When there are no elements in the specified range (e.g. length is zero) an empty list is returned

Exceptions
IndexOutOfBoundsException:
if the range specified with index and length is not within the range of the array, that is, if either of the following are true:
 index < 0 index > length() 
or if length != -1 and either of the following are true:
 length < 0 index + length > length()
lengthback to summary
public int length()

Returns the number of components in this array.

Returns:int

the integer count of components in this array.

setValueback to summary
public void setValue(int index, Value value) throws InvalidTypeException, ClassNotLoadedException

Replaces an array component with another value.

Object values must be assignment compatible with the component type (This implies that the component type must be loaded through the declaring class's class loader). Primitive values must be either assignment compatible with the component type or must be convertible to the component type without loss of information. See JLS section 5.2 for more information on assignment compatibility.

Parameters
index:int

the index of the component to set

value:Value

the new value

Exceptions
InvalidTypeException:
if the type of value is not compatible with the declared type of array components.
ClassNotLoadedException:
if the array component type has not yet been loaded through the appropriate class loader.
IndexOutOfBoundsException:
if index is outside the range of this array, that is, if either of the following are true:
 index < 0 index >= length() 
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
See Also
ArrayType#componentType()
setValuesback to summary
public void setValues(List<? extends Value> values) throws InvalidTypeException, ClassNotLoadedException

Replaces all array components with other values. If the given list is larger in size than the array, the values at the end of the list are ignored.

Object values must be assignment compatible with the element type (This implies that the component type must be loaded through the enclosing class's class loader). Primitive values must be either assignment compatible with the component type or must be convertible to the component type without loss of information. See JLS section 5.2 for more information on assignment compatibility.

Parameters
values:List<? extends Value>

a list of Value objects to be placed in this array. If values.size() is less that the length of the array, the first values.size() elements are set.

Exceptions
InvalidTypeException:
if any of the new values is not compatible with the declared type of array components.
ClassNotLoadedException:
if the array component type has not yet been loaded through the appropriate class loader.
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
See Also
ArrayType#componentType()
setValuesback to summary
public void setValues(int index, List<? extends Value> values, int srcIndex, int length) throws InvalidTypeException, ClassNotLoadedException

Replaces a range of array components with other values.

Object values must be assignment compatible with the component type (This implies that the component type must be loaded through the enclosing class's class loader). Primitive values must be either assignment compatible with the component type or must be convertible to the component type without loss of information. See JLS section 5.2 for more information on assignment compatibility.

Parameters
index:int

the index of the first component to set.

values:List<? extends Value>

a list of Value objects to be placed in this array.

srcIndex:int

the index of the first source value to use.

length:int

the number of components to set, or -1 to set all components to the end of this array or the end of values (whichever comes first).

Exceptions
InvalidTypeException:
if any element of values is not compatible with the declared type of array components.
IndexOutOfBoundsException:
if the array range specified with index and length is not within the range of the array, or if the source range specified with srcIndex and length is not within values, that is, if any of the following are true:
 index < 0 index > length() srcIndex < 0 srcIndex > values.size() 
or if length != -1 and any of the following are true:
 length < 0 index + length > length() srcIndex + length > values.size() 
VMCannotBeModifiedException:
if the VirtualMachine is read-only - see VirtualMachine#canBeModified().
See Also
ArrayType#componentType()