Package javassist.bytecode
Class FieldInfo
java.lang.Object
javassist.bytecode.FieldInfo
field_info
structure.
The following code adds a public field width
of int
type:
ClassFile cf = ... FieldInfo f = new FieldInfo(cf.getConstPool(), "width", "I"); f.setAccessFlags(AccessFlag.PUBLIC); cf.addField(f);
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(AttributeInfo info) Appends an attribute.int
Returns the access flags.getAttribute
(String name) Returns the attribute with the specified name.Returns all the attributes.int
Finds a ConstantValue attribute and returns the index into theconstant_pool
table.Returns the constant pool table used by thisfield_info
.Returns the field descriptor.getName()
Returns the field name.removeAttribute
(String name) Removes an attribute with the specified name.void
setAccessFlags
(int acc) Sets the access flags.void
setDescriptor
(String desc) Sets the field descriptor.void
Sets the field name.toString()
Returns a string representation of the object.
-
Constructor Details
-
FieldInfo
Constructs afield_info
structure.- Parameters:
cp
- a constant pool tablefieldName
- field namedesc
- field descriptor- See Also:
-
-
Method Details
-
toString
Returns a string representation of the object. -
getConstPool
Returns the constant pool table used by thisfield_info
. -
getName
Returns the field name. -
setName
Sets the field name. -
getAccessFlags
public int getAccessFlags()Returns the access flags.- See Also:
-
setAccessFlags
public void setAccessFlags(int acc) Sets the access flags.- See Also:
-
getDescriptor
Returns the field descriptor.- See Also:
-
setDescriptor
Sets the field descriptor.- See Also:
-
getConstantValue
public int getConstantValue()Finds a ConstantValue attribute and returns the index into theconstant_pool
table.- Returns:
- 0 if a ConstantValue attribute is not found.
-
getAttributes
Returns all the attributes. The returnedList
object is shared with this object. If you add a new attribute to the list, the attribute is also added to the field represented by this object. If you remove an attribute from the list, it is also removed from the field.- Returns:
- a list of
AttributeInfo
objects. - See Also:
-
getAttribute
Returns the attribute with the specified name. It returns null if the specified attribute is not found.An attribute name can be obtained by, for example,
AnnotationsAttribute.visibleTag
orAnnotationsAttribute.invisibleTag
.- Parameters:
name
- attribute name- See Also:
-
removeAttribute
Removes an attribute with the specified name.- Parameters:
name
- attribute name.- Returns:
- the removed attribute or null.
- Since:
- 3.21
-
addAttribute
Appends an attribute. If there is already an attribute with the same name, the new one substitutes for it.- See Also:
-