public final class FieldInfo extends Object
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);
CtField.getFieldInfo()
Constructor and Description |
---|
FieldInfo(ConstPool cp,
String fieldName,
String desc)
Constructs a
field_info structure. |
Modifier and Type | Method and Description |
---|---|
void |
addAttribute(AttributeInfo info)
Appends an attribute.
|
int |
getAccessFlags()
Returns the access flags.
|
AttributeInfo |
getAttribute(String name)
Returns the attribute with the specified name.
|
List |
getAttributes()
Returns all the attributes.
|
int |
getConstantValue()
Finds a ConstantValue attribute and returns the index into
the
constant_pool table. |
ConstPool |
getConstPool()
Returns the constant pool table used
by this
field_info . |
String |
getDescriptor()
Returns the field descriptor.
|
String |
getName()
Returns the field name.
|
AttributeInfo |
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 |
setName(String newName)
Sets the field name.
|
String |
toString()
Returns a string representation of the object.
|
public FieldInfo(ConstPool cp, String fieldName, String desc)
field_info
structure.cp
- a constant pool tablefieldName
- field namedesc
- field descriptorDescriptor
public String toString()
public ConstPool getConstPool()
field_info
.public String getName()
public void setName(String newName)
public int getAccessFlags()
AccessFlag
public void setAccessFlags(int acc)
AccessFlag
public String getDescriptor()
Descriptor
public void setDescriptor(String desc)
Descriptor
public int getConstantValue()
constant_pool
table.public List getAttributes()
List
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.AttributeInfo
objects.AttributeInfo
public AttributeInfo getAttribute(String name)
An attribute name can be obtained by, for example,
AnnotationsAttribute.visibleTag
or
AnnotationsAttribute.invisibleTag
.
name
- attribute namegetAttributes()
public AttributeInfo removeAttribute(String name)
name
- attribute name.public void addAttribute(AttributeInfo info)
getAttributes()
Copyright © 2020 Shigeru Chiba, www.javassist.org. All rights reserved.