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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAttribute(AttributeInfo info) Appends an attribute.intReturns the access flags.getAttribute(String name) Returns the attribute with the specified name.Returns all the attributes.intFinds a ConstantValue attribute and returns the index into theconstant_pooltable.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.voidsetAccessFlags(int acc) Sets the access flags.voidsetDescriptor(String desc) Sets the field descriptor.voidSets the field name.toString()Returns a string representation of the object.
-
Constructor Details
-
FieldInfo
Constructs afield_infostructure.- 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_pooltable.- Returns:
- 0 if a ConstantValue attribute is not found.
-
getAttributes
Returns all the attributes. The returnedListobject 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
AttributeInfoobjects. - 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.visibleTagorAnnotationsAttribute.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:
-