javassist.expr

Class NewArray

public class NewArray extends Expr

Array creation.

This class does not provide methods for obtaining the initial values of array elements.

Method Summary
CtClassgetComponentType()
Returns the type of array components.
intgetCreatedDimensions()
Returns the number of dimensions of arrays to be created.
intgetDimension()
Returns the dimension of the created array.
StringgetFileName()
Returns the source file containing the array creation.
intgetLineNumber()
Returns the line number of the source line containing the array creation.
CtClass[]mayThrow()
Returns the list of exceptions that the expression may throw.
voidreplace(String statement)
Replaces the array creation with the bytecode derived from the given source text.
CtBehaviorwhere()
Returns the method or constructor containing the array creation represented by this object.

Method Detail

getComponentType

public CtClass getComponentType()
Returns the type of array components. If the created array is a two-dimensional array of int, the type returned by this method is not int[] but int.

getCreatedDimensions

public int getCreatedDimensions()
Returns the number of dimensions of arrays to be created. If the opcode is multianewarray, this method returns the second operand. Otherwise, it returns 1.

getDimension

public int getDimension()
Returns the dimension of the created array.

getFileName

public String getFileName()
Returns the source file containing the array creation.

Returns: null if this information is not available.

getLineNumber

public int getLineNumber()
Returns the line number of the source line containing the array creation.

Returns: -1 if this information is not available.

mayThrow

public CtClass[] mayThrow()
Returns the list of exceptions that the expression may throw. This list includes both the exceptions that the try-catch statements including the expression can catch and the exceptions that the throws declaration allows the method to throw.

replace

public void replace(String statement)
Replaces the array creation with the bytecode derived from the given source text.

$0 is available even if the called method is static. If the field access is writing, $_ is available but the value of $_ is ignored.

Parameters: statement a Java statement.

where

public CtBehavior where()
Returns the method or constructor containing the array creation represented by this object.
Javassist, a Java-bytecode translator toolkit.
Copyright (C) 1999-2006 Shigeru Chiba. All Rights Reserved.