Methods Summary |
---|
public abstract void | accept(com.sun.org.apache.bcel.internal.generic.Visitor v)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.
|
private static final java.lang.String | className(short opcode)
String name = Constants.OPCODE_NAMES[opcode].toUpperCase();
/* ICONST_0, etc. will be shortened to ICONST, etc., since ICONST_0 and the like
* are not implemented (directly).
*/
try {
int len = name.length();
char ch1 = name.charAt(len - 2), ch2 = name.charAt(len - 1);
if((ch1 == '_") && (ch2 >= '0") && (ch2 <= '5"))
name = name.substring(0, len - 2);
if(name.equals("ICONST_M1")) // Special case
name = "ICONST";
} catch(StringIndexOutOfBoundsException e) { System.err.println(e); }
return "com.sun.org.apache.bcel.internal.generic." + name;
|
public int | consumeStack(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
return Constants.CONSUME_STACK[opcode];
|
public com.sun.org.apache.bcel.internal.generic.Instruction | 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.
Instruction i = null;
// "Constant" instruction, no need to duplicate
if(InstructionConstants.INSTRUCTIONS[this.getOpcode()] != null)
i = this;
else {
try {
i = (Instruction)clone();
} catch(CloneNotSupportedException e) {
System.err.println(e);
}
}
return i;
|
void | dispose()Some instructions may be reused, so don't do anything by default.
|
public void | dump(java.io.DataOutputStream out)Dump instruction as byte code to stream out.
out.writeByte(opcode); // Common for all instructions
|
public boolean | equals(java.lang.Object that)Check for equality, delegated to comparator
return (that instanceof Instruction)?
cmp.equals(this, (Instruction)that) : false;
|
public static com.sun.org.apache.bcel.internal.generic.InstructionComparator | getComparator()Get Comparator object used in the equals() method to determine
equality of instructions. return cmp;
|
public int | getLength() return length;
|
public java.lang.String | getName()
return Constants.OPCODE_NAMES[opcode];
|
public short | getOpcode() return opcode;
|
protected void | initFromFile(com.sun.org.apache.bcel.internal.util.ByteSequence bytes, boolean wide)Read needed data (e.g. index) from file.
|
public int | produceStack(com.sun.org.apache.bcel.internal.generic.ConstantPoolGen cpg)This method also gives right results for instructions whose
effect on the stack depends on the constant pool entry they
reference.
return Constants.PRODUCE_STACK[opcode];
|
public static final com.sun.org.apache.bcel.internal.generic.Instruction | readInstruction(com.sun.org.apache.bcel.internal.util.ByteSequence bytes)Read an instruction from (byte code) input stream and return the
appropiate object.
boolean wide = false;
short opcode = (short)bytes.readUnsignedByte();
Instruction obj = null;
if(opcode == Constants.WIDE) { // Read next opcode after wide byte
wide = true;
opcode = (short)bytes.readUnsignedByte();
}
if(InstructionConstants.INSTRUCTIONS[opcode] != null)
return InstructionConstants.INSTRUCTIONS[opcode]; // Used predefined immutable object, if available
/* Find appropiate class, instantiate an (empty) instruction object
* and initialize it by hand.
*/
Class clazz;
try {
clazz = Class.forName(className(opcode));
} catch (ClassNotFoundException cnfe){
// If a class by that name does not exist, the opcode is illegal.
// Note that IMPDEP1, IMPDEP2, BREAKPOINT are also illegal in a sense.
throw new ClassGenException("Illegal opcode detected.");
}
try {
obj = (Instruction)clazz.newInstance();
if(wide && !((obj instanceof LocalVariableInstruction) ||
(obj instanceof IINC) ||
(obj instanceof RET)))
throw new Exception("Illegal opcode after wide: " + opcode);
obj.setOpcode(opcode);
obj.initFromFile(bytes, wide); // Do further initializations, if any
// Byte code offset set in InstructionList
} catch(Exception e) { throw new ClassGenException(e.toString()); }
return obj;
|
public static void | setComparator(com.sun.org.apache.bcel.internal.generic.InstructionComparator c)Set comparator to be used for equals(). cmp = c;
|
private void | setOpcode(short opcode)Needed in readInstruction. this.opcode = opcode;
|
public java.lang.String | toString(boolean verbose)Long output format:
<name of opcode> "["<opcode number>"]"
"("<length of instruction>")"
if(verbose)
return getName() + "[" + opcode + "](" + length + ")";
else
return getName();
|
public java.lang.String | toString()
return toString(true);
|
public java.lang.String | toString(com.sun.org.apache.bcel.internal.classfile.ConstantPool cp)
return toString(false);
|