Package org.apache.bcel.generic
Class Instruction
java.lang.Object
org.apache.bcel.generic.Instruction
- All Implemented Interfaces:
Serializable
,Cloneable
- Direct Known Subclasses:
ACONST_NULL
,ArithmeticInstruction
,ArrayInstruction
,ARRAYLENGTH
,ATHROW
,BIPUSH
,BranchInstruction
,BREAKPOINT
,ConversionInstruction
,CPInstruction
,DCMPG
,DCMPL
,DCONST
,FCMPG
,FCMPL
,FCONST
,ICONST
,IMPDEP1
,IMPDEP2
,LCMP
,LCONST
,LocalVariableInstruction
,MONITORENTER
,MONITOREXIT
,NEWARRAY
,NOP
,RET
,ReturnInstruction
,SIPUSH
,StackInstruction
Abstract super class for all Java byte codes.
- Version:
- $Id: Instruction.java 386056 2006-03-15 11:31:56Z tcurdt $
- Author:
- M. Dahm
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
Call corresponding visitor method(s).int
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.copy()
Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are).void
dump
(DataOutputStream out) Dump instruction as byte code to stream out.boolean
Check for equality, delegated to comparatorstatic InstructionComparator
Get Comparator object used in the equals() method to determine equality of instructions.int
getName()
short
protected void
initFromFile
(ByteSequence bytes, boolean wide) Read needed data (e.g.int
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.static final Instruction
readInstruction
(ByteSequence bytes) Read an instruction from (byte code) input stream and return the appropiate object.static void
Set comparator to be used for equals().toString()
toString
(boolean verbose) Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"toString
(ConstantPool cp)
-
Field Details
-
length
protected short length -
opcode
protected short opcode
-
-
Constructor Details
-
Instruction
public Instruction(short opcode, short length)
-
-
Method Details
-
dump
Dump instruction as byte code to stream out.- Parameters:
out
- Output stream- Throws:
IOException
-
getName
- Returns:
- name of instruction, i.e., opcode name
-
toString
Long output format: <name of opcode> "["<opcode number>"]" "("<length of instruction>")"- Parameters:
verbose
- long/short format switch- Returns:
- mnemonic for instruction
-
toString
-
toString
- Returns:
- mnemonic for instruction with sumbolic references resolved
-
copy
Use with caution, since `BranchInstruction's have a `target' reference which is not copied correctly (only basic types are). This also applies for `Select' instructions with their multiple branch targets.- Returns:
- (shallow) copy of an instruction
- See Also:
-
initFromFile
Read needed data (e.g. index) from file.- Parameters:
bytes
- byte sequence to read fromwide
- "wide" instruction flag- Throws:
IOException
-
readInstruction
Read an instruction from (byte code) input stream and return the appropiate object.- Parameters:
bytes
- input stream bytes- Returns:
- instruction object being read
- Throws:
IOException
-
consumeStack
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.- Returns:
- Number of words consumed from stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically
-
produceStack
This method also gives right results for instructions whose effect on the stack depends on the constant pool entry they reference.- Returns:
- Number of words produced onto stack by this instruction, or Constants.UNPREDICTABLE, if this can not be computed statically
-
getOpcode
public short getOpcode()- Returns:
- this instructions opcode
-
getLength
public int getLength()- Returns:
- length (in bytes) of instruction
-
accept
Call corresponding visitor method(s). The order is: Call visitor methods of implemented interfaces first, then call methods according to the class hierarchy in descending order, i.e., the most specific visitXXX() call comes last.- Parameters:
v
- Visitor object
-
getComparator
Get Comparator object used in the equals() method to determine equality of instructions.- Returns:
- currently used comparator for equals()
-
setComparator
Set comparator to be used for equals(). -
equals
Check for equality, delegated to comparator
-