edu.rit.classfile
Class Instruction

java.lang.Object
  extended by edu.rit.classfile.Instruction
Direct Known Subclasses:
Location, SwitchInstruction

public abstract class Instruction
extends Object

Class Instruction encapsulates a Java bytecode instruction. To create a particular instruction, use the desired static field or method in class Op. For example:

     SynthesizedMethodDescription theMethod = . . .;
     ClassReference javaLangObject = NamedClassReference.JAVA_LANG_OBJECT;
     SubroutineReference javaLangObjectInit = new ConstructorReference (javaLangObject);
     . . .
     theMethod.addInstruction (Op.ALOAD (0));
     theMethod.addInstruction (Op.INVOKESPECIAL (javaLangObjectInit));
     theMethod.addInstruction (Op.RETURN);


Method Summary
abstract  byte[] getByteCodes()
          Returns a copy of this instruction's bytecodes.
abstract  int getLength()
          Returns this instruction's length, i.e., number of bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLength

public abstract int getLength()
Returns this instruction's length, i.e., number of bytes.


getByteCodes

public abstract byte[] getByteCodes()
                             throws ByteCodeException
Returns a copy of this instruction's bytecodes. (Altering the return value will not affect this instruction's bytecodes.)

Throws:
ByteCodeException - Thrown if there was a problem generating this instruction's bytecodes. The exception's detail message describes the problem.


Copyright © 2001-2006 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.