org.mozilla.classfile
public class ClassFileWriter extends Object
Field Summary | |
---|---|
static short | ACC_ABSTRACT |
static short | ACC_FINAL |
static short | ACC_NATIVE |
static short | ACC_PRIVATE |
static short | ACC_PROTECTED |
static short | ACC_PUBLIC |
static short | ACC_STATIC |
static short | ACC_SYNCHRONIZED |
static short | ACC_TRANSIENT |
static short | ACC_VOLATILE |
Constructor Summary | |
---|---|
ClassFileWriter(String className, String superClassName, String sourceFileName)
Construct a ClassFileWriter for a class.
|
Method Summary | |
---|---|
int | acquireLabel() |
void | add(int theOpCode)
Add the single-byte opcode to the current method.
|
void | add(int theOpCode, int theOperand)
Add a single-operand opcode to the current method.
|
void | add(int theOpCode, int theOperand1, int theOperand2)
Add the given two-operand bytecode to the current method.
|
void | add(int theOpCode, String className) |
void | add(int theOpCode, String className, String fieldName, String fieldType) |
void | addALoad(int local)
Load object from the given local into stack.
|
void | addAStore(int local)
Store object from stack top into the given local.
|
void | addDLoad(int local)
Load double from the given local into stack.
|
void | addDStore(int local)
Store double from stack top into the given local.
|
void | addExceptionHandler(int startLabel, int endLabel, int handlerLabel, String catchClassName) |
void | addField(String fieldName, String type, short flags)
Add a field to the class.
|
void | addField(String fieldName, String type, short flags, int value)
Add a field to the class.
|
void | addField(String fieldName, String type, short flags, long value)
Add a field to the class.
|
void | addField(String fieldName, String type, short flags, double value)
Add a field to the class.
|
void | addFLoad(int local)
Load float from the given local into stack.
|
void | addFStore(int local)
Store float from stack top into the given local.
|
void | addILoad(int local)
Load integer from the given local into stack.
|
void | addInterface(String interfaceName)
Add an interface implemented by this class.
|
void | addInvoke(int theOpCode, String className, String methodName, String methodType) |
void | addIStore(int local)
Store integer from stack top into the given local.
|
void | addLineNumberEntry(short lineNumber) |
void | addLLoad(int local)
Load long from the given local into stack.
|
void | addLoadConstant(int k)
Generate the load constant bytecode for the given integer.
|
void | addLoadConstant(long k)
Generate the load constant bytecode for the given long.
|
void | addLoadConstant(float k)
Generate the load constant bytecode for the given float.
|
void | addLoadConstant(double k)
Generate the load constant bytecode for the given double.
|
void | addLoadConstant(String k)
Generate the load constant bytecode for the given string.
|
void | addLoadThis()
Load "this" into stack. |
void | addLStore(int local)
Store long from stack top into the given local.
|
void | addPush(int k)
Generate code to load the given integer on stack.
|
void | addPush(boolean k) |
void | addPush(long k)
Generate code to load the given long on stack.
|
void | addPush(double k)
Generate code to load the given double on stack.
|
void | addPush(String k)
Generate the code to leave on stack the given string even if the
string encoding exeeds the class file limit for single string constant
|
int | addTableSwitch(int low, int high) |
void | addVariableDescriptor(String name, String type, int startPC, int register)
Add Information about java variable to use when generating the local
variable table.
|
void | adjustStackTop(int delta) |
static String | classNameToSignature(String name)
Convert Java class name in dot notation into
"Lname-with-dots-replaced-by-slashes;" form suitable for use as
JVM type signatures. |
String | getClassName() |
int | getCurrentCodeOffset()
Get the current offset into the code of the current method.
|
short | getStackTop() |
boolean | isUnderStringSizeLimit(String k)
Check if k fits limit on string constant size imposed by class file
format.
|
void | markHandler(int theLabel) |
void | markLabel(int label) |
void | markLabel(int label, short stackTop) |
void | markTableSwitchCase(int switchStart, int caseIndex) |
void | markTableSwitchCase(int switchStart, int caseIndex, int stackTop) |
void | markTableSwitchDefault(int switchStart) |
void | setFlags(short flags)
Set the class's flags.
|
void | setTableSwitchJump(int switchStart, int caseIndex, int jumpTarget) |
void | startMethod(String methodName, String type, short flags)
Add a method and begin adding code.
|
void | stopMethod(short maxLocals)
Complete generation of the method.
|
byte[] | toByteArray()
Get the class file as array of bytesto the OutputStream. |
void | write(OutputStream oStream)
Write the class file to the OutputStream.
|
Parameters: className the name of the class to write, including full package qualification. superClassName the name of the superclass of the class to write, including full package qualification. sourceFileName the name of the source file to use for producing debug information, or null if debug information is not desired
Parameters: theOpCode the opcode of the bytecode
Parameters: theOpCode the opcode of the bytecode theOperand the operand of the bytecode
Parameters: theOpCode the opcode of the bytecode theOperand1 the first operand of the bytecode theOperand2 the second operand of the bytecode
Parameters: local number of local register
Parameters: local number of local register
Parameters: local number of local register
Parameters: local number of local register
Parameters: fieldName the name of the field type the type of the field using ... flags the attributes of the field, such as ACC_PUBLIC, etc. bitwise or'd together
Parameters: fieldName the name of the field type the type of the field using ... flags the attributes of the field, such as ACC_PUBLIC, etc. bitwise or'd together value an initial integral value
Parameters: fieldName the name of the field type the type of the field using ... flags the attributes of the field, such as ACC_PUBLIC, etc. bitwise or'd together value an initial long value
Parameters: fieldName the name of the field type the type of the field using ... flags the attributes of the field, such as ACC_PUBLIC, etc. bitwise or'd together value an initial double value
Parameters: local number of local register
Parameters: local number of local register
Parameters: local number of local register
Parameters: interfaceName a name of an interface implemented by the class being written, including full package qualification.
Parameters: local number of local register
Parameters: local number of local register
Parameters: k the constant
Parameters: k the constant
Parameters: k the constant
Parameters: k the constant
Parameters: k the constant
Parameters: local number of local register
Parameters: k the constant
Parameters: k the constant
Parameters: k the constant
Parameters: k the constant
Parameters: name variable name. type variable type as bytecode descriptor string. startPC the starting bytecode PC where this variable is live, or -1 if it does not have a Java register. register the Java register number of variable or -1 if it does not have a Java register.
Returns: an integer representing the offset
Parameters: k the string constant
Parameters: flags the set of class flags to set
Parameters: methodName the name of the method type a string representing the type flags the attributes of the field, such as ACC_PUBLIC, etc. bitwise or'd together
startMethod
.
Parameters: maxLocals the maximum number of local variable slots (a.k.a. Java registers) used by the method vars the array of the variables for the method, or null if none
Parameters: oStream the stream to write to
Throws: IOException if writing to the stream produces an exception