Package serp.bytecode.lowlevel
Class Entry
java.lang.Object
serp.bytecode.lowlevel.Entry
- All Implemented Interfaces:
VisitAcceptor
- Direct Known Subclasses:
ClassEntry
,ComplexEntry
,DoubleEntry
,FloatEntry
,IntEntry
,InvokeDynamicEntry
,LongEntry
,MethodHandleEntry
,MethodTypeEntry
,NameAndTypeEntry
,StringEntry
,UTF8Entry
Base type for all constant pool entries. Entries should generally be
considered immutable; modifying an entry directly can have dire
consequences, and often renders the resulting class file invalid.
Entries cannot be shared among constant pools.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private ConstantPool
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
afterModify
(Object key) Subclasses must call this method when their state is mutated.(package private) Object
Subclasses must call this method before their state is mutated.static Entry
create
(int type) Create an entry based on its type code.int
getIndex()
Returns the index of the entry in the owning constant pool, or 0.getPool()
Returns the constant pool containing this entry, or null if none.abstract int
getType()
Return the type code for this entry type.boolean
isWide()
Return true if this is a wide entry -- i.e.static Entry
Read a single entry from the given bytecode stream and returns it.(package private) abstract void
This method is called after reading the entry type from bytecode.(package private) void
setIndex
(int index) Set the index of this entry within the pool.(package private) void
setPool
(ConstantPool pool) Sets the owning pool of the entry.static void
write
(Entry entry, DataOutput out) Write the given entry to the given bytecode stream.(package private) abstract void
writeData
(DataOutput out) This method is called after writing the entry type to bytecode.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
-
UTF8
public static final int UTF8- See Also:
-
INT
public static final int INT- See Also:
-
FLOAT
public static final int FLOAT- See Also:
-
LONG
public static final int LONG- See Also:
-
DOUBLE
public static final int DOUBLE- See Also:
-
CLASS
public static final int CLASS- See Also:
-
STRING
public static final int STRING- See Also:
-
FIELD
public static final int FIELD- See Also:
-
METHOD
public static final int METHOD- See Also:
-
INTERFACEMETHOD
public static final int INTERFACEMETHOD- See Also:
-
NAMEANDTYPE
public static final int NAMEANDTYPE- See Also:
-
METHODHANDLE
public static final int METHODHANDLE- See Also:
-
METHODTYPE
public static final int METHODTYPE- See Also:
-
INVOKEDYNAMIC
public static final int INVOKEDYNAMIC- See Also:
-
_pool
-
_index
private int _index
-
-
Constructor Details
-
Entry
public Entry()
-
-
Method Details
-
read
Read a single entry from the given bytecode stream and returns it.- Throws:
IOException
-
write
Write the given entry to the given bytecode stream.- Throws:
IOException
-
create
Create an entry based on its type code. -
getType
public abstract int getType()Return the type code for this entry type. -
isWide
public boolean isWide()Return true if this is a wide entry -- i.e. if it takes up two places in the constant pool. Returns false by default. -
getPool
Returns the constant pool containing this entry, or null if none. -
getIndex
public int getIndex()Returns the index of the entry in the owning constant pool, or 0. -
readData
This method is called after reading the entry type from bytecode. It should read all the data for this entry from the given stream.- Throws:
IOException
-
writeData
This method is called after writing the entry type to bytecode. It should write all data for this entry to the given stream.- Throws:
IOException
-
beforeModify
Object beforeModify()Subclasses must call this method before their state is mutated. -
afterModify
Subclasses must call this method when their state is mutated. -
setPool
Sets the owning pool of the entry. -
setIndex
void setIndex(int index) Set the index of this entry within the pool.
-