Class Expr

java.lang.Object
javassist.expr.Expr
All Implemented Interfaces:
Opcode
Direct Known Subclasses:
Cast, FieldAccess, Handler, Instanceof, MethodCall, NewArray, NewExpr

public abstract class Expr extends Object implements Opcode
Expression.
  • Method Details

    • 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 String getFileName()
      Returns the source file containing the expression.
      Returns:
      null if this information is not available.
    • replace

      public abstract void replace(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(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