Package serp.bytecode
Class Attribute
java.lang.Object
serp.bytecode.Attributes
serp.bytecode.Attribute
- All Implemented Interfaces:
BCEntity
,VisitAcceptor
- Direct Known Subclasses:
Annotations
,BootstrapMethods
,Code
,ConstantValue
,Deprecated
,Exceptions
,InnerClasses
,LineNumberTable
,LocalTable
,SourceFile
,Synthetic
,UnknownAttribute
In bytecode attributes are used to represent anything that is not
part of the class structure. This includes the source file name, code of
methods, the line number table, etc. All attributes contain at a minimum
an immutable name that also determines the attribute's type.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) static Attribute
create
(String name, Attributes owner) Create an attribute of the appropriate type based on the the attribute name.(package private) Collection
Return the collection used to hold the attributes of this entity.Return the class loader to use when loading related classes.(package private) int
Return the length of the bytecode representation of this attribute in bytes, excluding the name index.getName()
Return the name of this attribute.int
Return the index in theConstantPool
of theUTF8Entry
holding the name of this attribute.getOwner()
Return theAttributes
that owns this attribute.getPool()
Return the constant pool of the current class.Return the project of the current class.(package private) void
Invalidate this attribute.boolean
isValid()
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined.(package private) void
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index.(package private) void
Copy the information from the given attribute to this one.(package private) void
write
(DataOutput out, int length) Write the attribute bytecode to the given stream, up to length bytes, excluding the name index.Methods inherited from class serp.bytecode.Attributes
addAttribute, addAttribute, clearAttributes, getAttribute, getAttributes, getAttributes, readAttributes, removeAttribute, removeAttribute, setAttributes, visitAttributes, writeAttributes
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface serp.bytecode.visitor.VisitAcceptor
acceptVisit
-
Field Details
-
_nameIndex
private int _nameIndex -
_owner
-
-
Constructor Details
-
Attribute
Attribute(int nameIndex, Attributes owner)
-
-
Method Details
-
create
Create an attribute of the appropriate type based on the the attribute name. -
getOwner
Return theAttributes
that owns this attribute. The entity might be aBCClass
,BCField
,BCMethod
, or other attribute. -
getNameIndex
public int getNameIndex()Return the index in theConstantPool
of theUTF8Entry
holding the name of this attribute. -
getName
Return the name of this attribute. -
getProject
Description copied from interface:BCEntity
Return the project of the current class.- Specified by:
getProject
in interfaceBCEntity
-
getPool
Description copied from interface:BCEntity
Return the constant pool of the current class. -
getClassLoader
Description copied from interface:BCEntity
Return the class loader to use when loading related classes.- Specified by:
getClassLoader
in interfaceBCEntity
-
isValid
public boolean isValid()Description copied from interface:BCEntity
Return false if this entity has been removed from its parent; in this case the results of any operations on the entity are undefined. -
getAttributesHolder
Collection getAttributesHolder()Description copied from class:Attributes
Return the collection used to hold the attributes of this entity.- Specified by:
getAttributesHolder
in classAttributes
-
invalidate
void invalidate()Invalidate this attribute. -
getLength
int getLength()Return the length of the bytecode representation of this attribute in bytes, excluding the name index. -
read
Copy the information from the given attribute to this one. Does nothing by default. -
read
Read the attribute bytecode from the given stream, up to length bytes, excluding the name index. Does nothing by default.- Throws:
IOException
-
write
Write the attribute bytecode to the given stream, up to length bytes, excluding the name index. Does nothing by default.- Throws:
IOException
-