Class NewArray

  • All Implemented Interfaces:

    public class NewArray
    extends Expr
    Array creation.

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

    • Method Detail

      • where

        public CtBehavior where()
        Returns the method or constructor containing the array creation represented by this object.
        where in class Expr
      • getLineNumber

        public int getLineNumber()
        Returns the line number of the source line containing the array creation.
        getLineNumber in class Expr
        -1 if this information is not available.
      • getFileName

        public java.lang.String getFileName()
        Returns the source file containing the array creation.
        getFileName in class Expr
        null 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.
        mayThrow in class Expr
      • getComponentType

        public CtClass getComponentType()
                                 throws NotFoundException
        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.
      • getDimension

        public int getDimension()
        Returns the dimension of the created array.
      • 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.
      • replace

        public void replace​(java.lang.String statement)
                     throws CannotCompileException
        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.

        Specified by:
        replace in class Expr
        statement - a Java statement except try-catch.