Class Expr

    • Method Detail

      • getEnclosingClass

        public CtClass getEnclosingClass()
        Returns the class that declares the method enclosing this expression.
        Since:
        3.7
      • where

        public CtBehavior where()
        Returns the constructor or method containing the expression.
      • 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.
      • indexOfBytecode

        public int indexOfBytecode()
        Returns the index of the bytecode corresponding to the expression. It is the index into the byte array containing the Java bytecode that implements the method.
      • getLineNumber

        public int getLineNumber()
        Returns the line number of the source line containing the expression.
        Returns:
        -1 if this information is not available.
      • getFileName

        public java.lang.String getFileName()
        Returns the source file containing the expression.
        Returns:
        null if this information is not available.
      • replace

        public abstract void replace​(java.lang.String statement)
                              throws CannotCompileException
        Replaces this expression with the bytecode derived from the given source text.
        Parameters:
        statement - a Java statement except try-catch.
        Throws:
        CannotCompileException
      • replace

        public void replace​(java.lang.String statement,
                            ExprEditor recursive)
                     throws CannotCompileException
        Replaces this expression with the bytecode derived from the given source text and ExprEditor.
        Parameters:
        statement - a Java statement except try-catch.
        recursive - if not null, the substituted bytecode is recursively processed by the given ExprEditor.
        Throws:
        CannotCompileException
        Since:
        3.1