javassist.expr

Class FieldAccess

public class FieldAccess extends Expr

Expression for accessing a field.
Method Summary
StringgetClassName()
Returns the name of the class in which the field is declared.
CtFieldgetField()
Returns the field accessed by this expression.
StringgetFieldName()
Returns the name of the field.
StringgetFileName()
Returns the source file containing the field access.
intgetLineNumber()
Returns the line number of the source line containing the field access.
StringgetSignature()
Returns the signature of the field type.
booleanisReader()
Returns true if the field is read.
booleanisStatic()
Returns true if the field is static.
booleanisWriter()
Returns true if the field is written in.
CtClass[]mayThrow()
Returns the list of exceptions that the expression may throw.
voidreplace(String statement)
Replaces the method call with the bytecode derived from the given source text.
CtBehaviorwhere()
Returns the method or constructor containing the field-access expression represented by this object.

Method Detail

getClassName

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

getField

public CtField getField()
Returns the field accessed by this expression.

getFieldName

public String getFieldName()
Returns the name of the field.

getFileName

public String getFileName()
Returns the source file containing the field access.

Returns: null if this information is not available.

getLineNumber

public int getLineNumber()
Returns the line number of the source line containing the field access.

Returns: -1 if this information is not available.

getSignature

public 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

isReader

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

isStatic

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

isWriter

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

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 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.

Parameters: statement a Java statement.

where

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