public abstract class Instruction extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected short |
length
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
protected short |
opcode
Deprecated.
(since 6.0) will be made private; do not access directly, use getter/setter
|
Constructor and Description |
---|
Instruction(short opcode,
short length) |
Modifier and Type | Method and Description |
---|---|
abstract void |
accept(Visitor v)
Call corresponding visitor method(s).
|
int |
consumeStack(ConstantPoolGen cpg)
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry
they reference.
|
Instruction |
copy()
Use with caution, since 'BranchInstruction's have a 'target' reference which is not copied correctly (only basic
types are).
|
void |
dump(DataOutputStream out)
Dumps instruction as byte code to stream out.
|
boolean |
equals(Object that)
Tests for equality, delegated to comparator
|
static InstructionComparator |
getComparator()
Deprecated.
(6.0) use the built in comparator, or wrap this class in another object that implements these methods
|
int |
getLength() |
String |
getName() |
short |
getOpcode() |
int |
hashCode()
Gets the hashCode of this object.
|
protected void |
initFromFile(ByteSequence bytes,
boolean wide)
Reads needed data (e.g.
|
static boolean |
isValidByte(int value)
Tests if the value can fit in a byte (signed)
|
static boolean |
isValidShort(int value)
Tests if the value can fit in a short (signed)
|
int |
produceStack(ConstantPoolGen cpg)
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry
they reference.
|
static Instruction |
readInstruction(ByteSequence bytes)
Reads an instruction from (byte code) input stream and return the appropriate object.
|
static void |
setComparator(InstructionComparator c)
Deprecated.
(6.0) use the built in comparator, or wrap this class in another object that implements these methods
|
String |
toString() |
String |
toString(boolean verbose)
Long output format:
<name of opcode> "["<opcode number>"]" "("<length of instruction>")"
|
String |
toString(ConstantPool cp) |
@Deprecated protected short length
@Deprecated protected short opcode
public Instruction(short opcode, short length)
@Deprecated public static InstructionComparator getComparator()
public static boolean isValidByte(int value)
value
- the value to checkpublic static boolean isValidShort(int value)
value
- the value to checkpublic static Instruction readInstruction(ByteSequence bytes) throws IOException
If the Instruction is defined in InstructionConst
, then the singleton instance is returned.
bytes
- input stream bytesIOException
- Thrown when an I/O exception of some sort has occurred.InstructionConst.getInstruction(int)
@Deprecated public static void setComparator(InstructionComparator c)
public abstract void accept(Visitor v)
v
- Visitor objectpublic int consumeStack(ConstantPoolGen cpg)
public Instruction copy()
BranchInstruction
public void dump(DataOutputStream out) throws IOException
out
- Output streamIOException
- Thrown when an I/O exception of some sort has occurred.public int getLength()
public short getOpcode()
public int hashCode()
protected void initFromFile(ByteSequence bytes, boolean wide) throws IOException
bytes
- byte sequence to read fromwide
- "wide" instruction flagIOException
- may be thrown if the implementation needs to read data from the filepublic int produceStack(ConstantPoolGen cpg)
public String toString(boolean verbose)
verbose
- long/short format switchpublic String toString(ConstantPool cp)
Copyright © 2004–2022 The Apache Software Foundation. All rights reserved.