|
Java API by Zvi Har’El |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcf.CodeAttribute
class CodeAttribute
An instance of class CodeAttribute is an in-core representation
of a “Code” attribute of a method.
| Field Summary | |
|---|---|
(package private) Vector |
attributes
Attributes of this code. |
(package private) ClassFile |
cf
The ClassFile object to which this code belongs. |
(package private) byte[] |
code
The actual JVM bytecode for this method. |
(package private) int |
codeLength
Number of bytes in the code array. |
(package private) Vector |
exceptionTable
The exception table. |
(package private) short |
maxLocals
Maximum number of words in the local variable pool of this method. |
(package private) short |
maxStack
Maximum number of words on the operand stack during the method execution. |
| Constructor Summary | |
|---|---|
CodeAttribute(ClassFile cf)
Constructs an empty CodeAttribute object for a new method. |
|
CodeAttribute(DataInputStream in,
ClassFile cf)
Constructs a new CodeAttribute object by reading an input
stream. |
|
| Method Summary | |
|---|---|
(package private) void |
addException(int start,
int end,
int handler,
String type)
Adds an exception to the exception table of a method. |
(package private) void |
ldc(double c)
Generates code to push a DOUBLE constant into the
stack. |
(package private) void |
ldc(float c)
Generates code to push a FLOAT constant into the
stack. |
(package private) void |
ldc(int c)
Generates code to push a INTEGER constant into the
stack. |
(package private) void |
ldc(long c)
Generates code to push a LONG constant into the
stack. |
private void |
ldc(short i)
Generates code to push an INTEGER, a
FLOAT, or a STRING constant into the
stack. |
(package private) void |
ldc(String c)
Generates code to push null or a STRING
constant into the stack. |
(package private) void |
move(int n,
byte op)
Generates byte code to move data to or from a local variable. |
(package private) void |
pad()
Pads the code array with zero bytes. |
(package private) void |
pad(int n)
Pads the code array with zero bytes. |
(package private) void |
put(byte i)
Puts a byte in the first available location of the code array. |
(package private) void |
put(byte i,
int l)
Puts a byte in a specified location of the code array. |
(package private) void |
put(byte tag,
short i,
String s1,
String s2)
Puts an index to the constant pool in the first available location of the code array. |
(package private) void |
put(byte tag,
String s)
Puts an index to the constant pool in the first available location of the code array. |
(package private) void |
put(byte tag,
String s1,
String s2,
String s3)
Puts an index to the constant pool in the first available location of the code array. |
(package private) void |
put(short i)
Puts two bytes in the first available location of the code array. |
(package private) void |
put(short i,
int l)
Puts two bytes in a specified location of the code array. |
(package private) void |
strip()
Strip attributes. |
(package private) void |
trim()
Trim the code array to actual code length. |
(package private) void |
write(DataOutputStream out)
Writes the CodeAttribute object on an output stream. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
short maxStack
short maxLocals
int codeLength
byte[] code
final Vector exceptionTable
Long object, packing
four short values, as follows: The start and end of the
code for which the exception handler is active, the start of the
exception handler, and the type of the handled exception given as an
index to a CLASS constant.
final Vector attributes
“LineNumberTable” and
“LocalVariableTable”. Each entry is a byte array.
ClassFile cf
ClassFile object to which this code belongs. Used
to access the constant pool.
| Constructor Detail |
|---|
CodeAttribute(DataInputStream in,
ClassFile cf)
throws IOException
CodeAttribute object by reading an input
stream.
in - the input streamcf - the ClassFile object to which this CodeAttribute object belongs
IOException - if input error occursCodeAttribute(ClassFile cf)
CodeAttribute object for a new method.
The code array initial allocation is 256 bytes.
cf - the ClassFile object to which this CodeAttribute object belongs| Method Detail |
|---|
final void write(DataOutputStream out)
throws IOException
CodeAttribute object on an output stream.
out - the output stream
IOException - if output error occursfinal void strip()
final void addException(int start,
int end,
int handler,
String type)
start - the start of the code for which the handler is activeend - the end of the code for which the handler is activehandler - the start of the exception handlertype - the type of exception caught by this handlerfinal void trim()
final void put(byte i,
int l)
throws IndexOutOfBoundsException
i - the bytel - the location
IndexOutOfBoundsException - if the reqested location is outside
the code array
final void put(short i,
int l)
throws IndexOutOfBoundsException
i - the bytesl - the location
IndexOutOfBoundsException - if the reqested location is outside the code arrayfinal void put(byte i)
i - the bytefinal void put(short i)
i - the bytes
final void put(byte tag,
String s)
tag - a constant pool tags - a String valueClassFile.cp(byte,String)
final void put(byte tag,
String s1,
String s2,
String s3)
tag - a constant pool tags1 - a String values2 - a String values3 - a String valueClassFile.cp(byte,String,String,String)
final void put(byte tag,
short i,
String s1,
String s2)
tag - a constant pool tagi - a short values1 - a String values2 - a String valueClassFile.cp(byte,short,String,String)final void pad(int n)
n - the number of padding bytesfinal void pad()
private final void ldc(short i)
INTEGER, a
FLOAT, or a STRING constant into the
stack. The JVM operation most efficient for the size of the index
of the constant in the pool is selected.
i - an index to the constant poolfinal void ldc(int c)
INTEGER constant into the
stack.
c - a int valueldc(short),
JVM Spec §6.4: iconst_<i>,
bipush,
sipushfinal void ldc(long c)
LONG constant into the
stack.
c - a long valuefinal void ldc(float c)
FLOAT constant into the
stack.
c - a float valueldc(short),
JVM Spec §6.4: fconst_<f>final void ldc(double c)
DOUBLE constant into the
stack.
c - a double valuefinal void ldc(String c)
null or a STRING
constant into the stack.
c - null or a String valueldc(short),
JVM Spec §6.4: aconst_null
final void move(int n,
byte op)
n - the local variableop - the opcode: ILOAD, ISTORE, etc.
|
Java API by Zvi Har’El |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||