Class FieldAccess

  • All Implemented Interfaces:
    Opcode

    public class FieldAccess
    extends Expr
    Expression for accessing a field.
    • Method Detail

      • where

        public CtBehavior where()
        Returns the method or constructor containing the field-access expression represented by this object.
        Overrides:
        where in class Expr
      • getLineNumber

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

        public java.lang.String getFileName()
        Returns the source file containing the field access.
        Overrides:
        getFileName in class Expr
        Returns:
        null if this information is not available.
      • isStatic

        public boolean isStatic()
        Returns true if the field is static.
      • isReader

        public boolean isReader()
        Returns true if the field is read.
      • isWriter

        public boolean isWriter()
        Returns true if the field is written in.
      • getClassName

        public java.lang.String getClassName()
        Returns the name of the class in which the field is declared.
      • getFieldName

        public java.lang.String getFieldName()
        Returns the name of the field.
      • 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.
        Overrides:
        mayThrow in class Expr
      • getSignature

        public java.lang.String getSignature()
        Returns the signature of the field type. The signature is represented by a character string called field descriptor, which is defined in the JVM specification.
        Since:
        3.1
        See Also:
        Descriptor.toCtClass(String, ClassPool)
      • replace

        public void replace​(java.lang.String statement)
                     throws CannotCompileException
        Replaces the method call 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
        Parameters:
        statement - a Java statement except try-catch.
        Throws:
        CannotCompileException