# Interface ArrayType

All Superinterfaces:
  `Accessible, Comparable<ReferenceType>, Mirror, ReferenceType, Type`

public interface ArrayType extends ReferenceType
Provides access to the class of an array and the type of its components in the target VM.

Since:
  1.3
See Also:
  - `ArrayReference`

## Method Summary

Modifier and Type
Method
Description
`String`
`componentSignature()`
Gets the JNI signature of the components of this array class.
`Type`
`componentType()`
Returns the component type of this array, as specified in the array declaration.
`String`
`componentTypeName()`
Returns a text representation of the component type of this array.
`ArrayReference`
`newInstance(int length)`
Creates a new instance of this array class in the target VM.

### Methods declared in interface Accessible

`isPackagePrivate, isPrivate, isProtected, isPublic, modifiers`
Modifier and Type
Method
Description
`boolean`
`isPackagePrivate()`
Determines if this object mirrors a package private item.
`boolean`
`isPrivate()`
Determines if this object mirrors a private item.
`boolean`
`isProtected()`
Determines if this object mirrors a protected item.
`boolean`
`isPublic()`
Determines if this object mirrors a public item.
`int`
`modifiers()`
Returns the Java programming language modifiers, encoded in an integer.

### Methods declared in interface Comparable

`compareTo`
Modifier and Type
Method
Description
`int`
`compareTo(ReferenceType o)`
Compares this object with the specified object for order.

### Methods declared in interface Mirror

`toString, virtualMachine`
Modifier and Type
Method
Description
`String`
`toString()`
Returns a String describing this mirror
`VirtualMachine`
`virtualMachine()`
Gets the VirtualMachine to which this Mirror belongs.

### Methods declared in interface ReferenceType

`allFields, allLineLocations, allLineLocations, allMethods, availableStrata, classLoader, classObject, constantPool, constantPoolCount, defaultStratum, equals, failedToInitialize, fieldByName, fields, genericSignature, getValue, getValues, hashCode, instances, isAbstract, isFinal, isInitialized, isPrepared, isStatic, isVerified, locationsOfLine, locationsOfLine, majorVersion, methods, methodsByName, methodsByName, minorVersion, module, name, nestedTypes, sourceDebugExtension, sourceName, sourceNames, sourcePaths, visibleFields, visibleMethods`
Modifier and Type
Method
Description
`List<Field>`
`allFields()`
Returns a list containing each `Field` declared in this type, and its superclasses, implemented interfaces, and/or superinterfaces.
`List<Location>`
`allLineLocations()`
Returns a list containing a `Location` object for each executable source line in this reference type.
`List<Location>`
`allLineLocations(String stratum, String sourceName)`
Returns a list containing a `Location` object for each executable source line in this reference type.
`List<Method>`
`allMethods()`
Returns a list containing each `Method` declared in this type, and its superclasses, implemented interfaces, and/or superinterfaces.
`List<String>`
`availableStrata()`
Return the available strata for this reference type.
`ClassLoaderReference`
`classLoader()`
Gets the classloader object which loaded the class corresponding to this type.
`ClassObjectReference`
`classObject()`
Returns the class object that corresponds to this type in the target VM.
`byte[]`
`constantPool()`
Returns the raw bytes of the constant pool in the format of the constant_pool item of the Class File Format in the Java Virtual Machine Specification.
`int`
`constantPoolCount()`
Returns the number of entries in the constant pool plus one.
`String`
`defaultStratum()`
Returns the default stratum for this reference type.
`boolean`
`equals(Object obj)`
Compares the specified Object with this ReferenceType for equality.
`boolean`
`failedToInitialize()`
Determines if initialization failed for this class.
`Field`
`fieldByName(String fieldName)`
Finds the visible `Field` with the given non-ambiguous name.
`List<Field>`
`fields()`
Returns a list containing each `Field` declared in this type.
`String`
`genericSignature()`
Gets the generic signature for this type if there is one.
`Value`
`getValue(Field field)`
Gets the `Value` of a given static `Field` in this type.
`Map<Field,Value>`
`getValues(List<? extends Field> fields)`
Returns a map containing the `Value` of each static `Field` in the given list.
`int`
`hashCode()`
Returns the hash code value for this ObjectReference.
`List<ObjectReference>`
`instances(long maxInstances)`
Returns instances of this ReferenceType.
`boolean`
`isAbstract()`
Determines if this type was declared abstract.
`boolean`
`isFinal()`
Determines if this type was declared final.
`boolean`
`isInitialized()`
Determines if this type has been initialized.
`boolean`
`isPrepared()`
Determines if this type has been prepared.
`boolean`
`isStatic()`
Determines if this type was declared static.
`boolean`
`isVerified()`
Determines if this type has been verified.
`List<Location>`
`locationsOfLine(int lineNumber)`
Returns a List containing all `Location` objects that map to the given line number.
`List<Location>`
`locationsOfLine(String stratum, String sourceName, int lineNumber)`
Returns a List containing all `Location` objects that map to the given line number.
`int`
`majorVersion()`
Returns the class major version number, as defined in the class file format of the Java Virtual Machine Specification.
`List<Method>`
`methods()`
Returns a list containing each `Method` declared directly in this type.
`List<Method>`
`methodsByName(String name)`
Returns a List containing each visible `Method` that has the given name.
`List<Method>`
`methodsByName(String name, String signature)`
Returns a List containing each visible `Method` that has the given name and signature.
`int`
`minorVersion()`
Returns the class minor version number, as defined in the class file format of the Java Virtual Machine Specification.
`default ModuleReference`
`module()`
Gets the module object which contains the class corresponding to this type.
`String`
`name()`
Returns the name of this `ReferenceType` object.
`List<ReferenceType>`
`nestedTypes()`
Returns a List containing `ReferenceType` objects that are declared within this type and are currently loaded into the Virtual Machine.
`String`
`sourceDebugExtension()`
Get the source debug extension of this type.
`String`
`sourceName()`
Gets an identifying name for the source corresponding to the declaration of this type.
`List<String>`
`sourceNames(String stratum)`
Gets the identifying names for all the source corresponding to the declaration of this type.
`List<String>`
`sourcePaths(String stratum)`
Gets the paths to the source corresponding to the declaration of this type.
`List<Field>`
`visibleFields()`
Returns a list containing each unhidden and unambiguous `Field` in this type.
`List<Method>`
`visibleMethods()`
Returns a list containing each `Method` declared or inherited by this type.

### Methods declared in interface Type

`signature`
Modifier and Type
Method
Description
`String`
`signature()`
Returns the type signature for this type.

## Method Details

### newInstance

ArrayReference newInstance(int length)
Creates a new instance of this array class in the target VM. The array is created with the given length and each component is initialized to is standard default value.

Parameters:
  `length` - the number of components in the new array
Returns:
  the newly created `ArrayReference` mirroring the new object in the target VM.
Throws:
  `VMCannotBeModifiedException` - if the VirtualMachine is read-only - see `VirtualMachine.canBeModified()`.

### componentSignature

String componentSignature()
Gets the JNI signature of the components of this array class. The signature describes the declared type of the components. If the components are objects, their actual type in a particular run-time context may be a subclass of the declared class.

Returns:
  a string containing the JNI signature of array components.

### componentTypeName

String componentTypeName()
Returns a text representation of the component type of this array.

Returns:
  a text representation of the component type.

### componentType

Type componentType() throws ClassNotLoadedException
Returns the component type of this array, as specified in the array declaration.

Note: The component type of a array will always be created or loaded before the array - see The Java Virtual Machine Specification, section 5.3.3 - Creating Array Classes. However, although the component type will be loaded it may not yet be prepared, in which case the type will be returned but attempts to perform some operations on the returned type (e.g. `fields()`) will throw a `ClassNotPreparedException`. Use `ReferenceType.isPrepared()` to determine if a reference type is prepared.

Returns:
  the `Type` of this array's components.
Throws:
  `ClassNotLoadedException`
See Also:
  - `Type`
  - Field.type() - for usage examples