|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.mozilla.javascript.LabelTable | +--org.mozilla.classfile.ClassFileWriter
ClassFileWriter A ClassFileWriter is used to write a Java class file. Methods are provided to create fields and methods, and within methods to write Java bytecodes.
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(java.lang.String className,
java.lang.String superClassName,
java.lang.String sourceFileName)
Construct a ClassFileWriter for a class. |
Method Summary | |
void |
add(byte theOpCode)
Add the single-byte opcode to the current method. |
void |
add(byte theOpCode,
int theOperand)
Add a single-operand opcode to the current method. |
void |
add(byte theOpCode,
int theOperand1,
int theOperand2)
Add the given two-operand bytecode to the current method. |
void |
add(byte theOpCode,
java.lang.String className)
|
void |
add(byte theOpCode,
java.lang.String className,
java.lang.String fieldName,
java.lang.String fieldType)
|
void |
add(byte theOpCode,
java.lang.String className,
java.lang.String methodName,
java.lang.String parametersType,
java.lang.String returnType)
|
void |
addExceptionHandler(int startLabel,
int endLabel,
int handlerLabel,
java.lang.String catchClassName)
|
void |
addField(java.lang.String fieldName,
java.lang.String type,
short flags)
Add a field to the class. |
void |
addField(java.lang.String fieldName,
java.lang.String type,
short flags,
double value)
Add a field to the class. |
void |
addField(java.lang.String fieldName,
java.lang.String type,
short flags,
int value)
Add a field to the class. |
void |
addField(java.lang.String fieldName,
java.lang.String type,
short flags,
long value)
Add a field to the class. |
void |
addInterface(java.lang.String interfaceName)
Add an interface implemented by this class. |
void |
addLineNumberEntry(short lineNumber)
|
void |
addLoadConstant(double k)
Generate the load constant bytecode for the given double. |
void |
addLoadConstant(float k)
Generate the load constant bytecode for the given float. |
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(java.lang.String k)
Generate the load constant bytecode for the given string. |
void |
addToCodeBuffer(byte b)
|
void |
adjustStackTop(int delta)
|
static java.lang.String |
fullyQualifiedForm(java.lang.String name)
|
int |
getCurrentCodeOffset()
Get the current offset into the code of the current method. |
short |
getStackTop()
|
int |
markHandler(int theLabel)
|
int |
markLabel(int theLabel)
|
int |
markLabel(int theLabel,
short stackTop)
|
void |
setFlags(short flags)
Set the class's flags. |
void |
startMethod(java.lang.String methodName,
java.lang.String type,
short flags)
Add a method and begin adding code. |
void |
stopMethod(short maxLocals,
VariableTable vars)
Complete generation of the method. |
void |
write(java.io.OutputStream oStream)
Write the class file to the OutputStream. |
Methods inherited from class org.mozilla.javascript.LabelTable |
acquireLabel, markLabel |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final short ACC_PUBLIC
public static final short ACC_PRIVATE
public static final short ACC_PROTECTED
public static final short ACC_STATIC
public static final short ACC_FINAL
public static final short ACC_SYNCHRONIZED
public static final short ACC_VOLATILE
public static final short ACC_TRANSIENT
public static final short ACC_NATIVE
public static final short ACC_ABSTRACT
Constructor Detail |
public ClassFileWriter(java.lang.String className, java.lang.String superClassName, java.lang.String sourceFileName)
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 desiredMethod Detail |
public void addInterface(java.lang.String interfaceName)
interfaceName
- a name of an interface implemented
by the class being written, including full package
qualification.public void setFlags(short flags)
flags
- the set of class flags to setpublic static java.lang.String fullyQualifiedForm(java.lang.String name)
public void addField(java.lang.String fieldName, java.lang.String type, short flags)
fieldName
- the name of the fieldtype
- the type of the field using ...flags
- the attributes of the field, such as ACC_PUBLIC, etc.
bitwise or'd togetherpublic void addField(java.lang.String fieldName, java.lang.String type, short flags, int value)
fieldName
- the name of the fieldtype
- the type of the field using ...flags
- the attributes of the field, such as ACC_PUBLIC, etc.
bitwise or'd togethervalue
- an initial integral valuepublic void addField(java.lang.String fieldName, java.lang.String type, short flags, long value)
fieldName
- the name of the fieldtype
- the type of the field using ...flags
- the attributes of the field, such as ACC_PUBLIC, etc.
bitwise or'd togethervalue
- an initial long valuepublic void addField(java.lang.String fieldName, java.lang.String type, short flags, double value)
fieldName
- the name of the fieldtype
- the type of the field using ...flags
- the attributes of the field, such as ACC_PUBLIC, etc.
bitwise or'd togethervalue
- an initial double valuepublic void startMethod(java.lang.String methodName, java.lang.String type, short flags)
methodName
- the name of the methodtype
- a string representing the typeflags
- the attributes of the field, such as ACC_PUBLIC, etc.
bitwise or'd togetherpublic void stopMethod(short maxLocals, VariableTable vars)
startMethod
.maxLocals
- the maximum number of local variable slots
(a.k.a. Java registers) used by the methodvars
- the VariableTable of the variables for the method,
or null if nonepublic void add(byte theOpCode)
theOpCode
- the opcode of the bytecodepublic void add(byte theOpCode, int theOperand)
theOpCode
- the opcode of the bytecodetheOperand
- the operand of the bytecodepublic void addLoadConstant(int k)
k
- the constantpublic void addLoadConstant(long k)
k
- the constantpublic void addLoadConstant(float k)
k
- the constantpublic void addLoadConstant(double k)
k
- the constantpublic void addLoadConstant(java.lang.String k)
k
- the constantpublic void add(byte theOpCode, int theOperand1, int theOperand2)
theOpCode
- the opcode of the bytecodetheOperand1
- the first operand of the bytecodetheOperand2
- the second operand of the bytecodepublic void add(byte theOpCode, java.lang.String className)
public void add(byte theOpCode, java.lang.String className, java.lang.String fieldName, java.lang.String fieldType)
public void add(byte theOpCode, java.lang.String className, java.lang.String methodName, java.lang.String parametersType, java.lang.String returnType)
public int markLabel(int theLabel)
public int markLabel(int theLabel, short stackTop)
public int markHandler(int theLabel)
public int getCurrentCodeOffset()
public short getStackTop()
public void adjustStackTop(int delta)
public void addToCodeBuffer(byte b)
public void addExceptionHandler(int startLabel, int endLabel, int handlerLabel, java.lang.String catchClassName)
public void addLineNumberEntry(short lineNumber)
public void write(java.io.OutputStream oStream) throws java.io.IOException
oStream
- the stream to write tojava.io.IOException
- if writing to the stream produces an exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |