Class Code
- java.lang.Object
-
- org.fife.rsta.ac.java.classreader.attributes.AttributeInfo
-
- org.fife.rsta.ac.java.classreader.attributes.Code
-
public class Code extends AttributeInfo
A variable-length attribute used in the attributes table ofMethodInfostructures. ACodeattribute contains the JVM instructions and auxiliary information for a single method, instance initialization method, or class or interface initialization method. Every JVM implementation must recognizeCodeattributes. If the method is eithernativeorabstract, itsMethodInfostructure must not have aCodeattribute. Otherwise, itsMethodInfostructure must have exactly oneCodeattribute.- Version:
- 1.0
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<AttributeInfo>attributesAttributes of thisCodeattribute.private intcodeLengthThe size of the method's code, in bytes.private ExceptionTableEntry[]exceptionTableThe exception handlers in thecodearray.private static java.lang.StringLINE_NUMBER_TABLEprivate static java.lang.StringLOCAL_VARIABLE_TABLEprivate static java.lang.StringLOCAL_VARIABLE_TYPE_TABLEprivate intmaxLocalsThe number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.private intmaxStackThe maximum depth of the operand stack of this method at any point during its execution.private MethodInfomiThe parent method.private java.lang.String[]paramNamesThe names of parameters to the parent method, if debugging was enabled during compilation.private static java.lang.StringSTACK_MAP_TABLE
-
Constructor Summary
Constructors Constructor Description Code(MethodInfo mi)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetCodeLength()Returns the length of the code array, in bytes.intgetMaxLocals()Returns the number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.intgetMaxStack()Returns the maximum depth of the operand stack of this method at any point during its execution.MethodInfogetMethodInfo()Returns the method containing this code.java.lang.StringgetParameterName(int index)If debugging was enabled during compilation, this method returns the name of the given parameter to this method.static Coderead(MethodInfo mi, java.io.DataInputStream in)Reads aCodeattribute from an input stream.private AttributeInforeadAttribute(java.io.DataInputStream in)Reads an attribute for thisCodeattribute from an input stream.-
Methods inherited from class org.fife.rsta.ac.java.classreader.attributes.AttributeInfo
getClassFile, getName, readUnsupportedAttribute
-
-
-
-
Field Detail
-
mi
private MethodInfo mi
The parent method.
-
maxStack
private int maxStack
The maximum depth of the operand stack of this method at any point during its execution.
-
maxLocals
private int maxLocals
The number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.The greatest local variable index for a value of type
longordoubleismaxLocals-2. The greatest local variable index for a value of any other type ismaxLocals-1.
-
codeLength
private int codeLength
The size of the method's code, in bytes.
-
exceptionTable
private ExceptionTableEntry[] exceptionTable
The exception handlers in thecodearray. The order of the handlers in this table is significant.
-
paramNames
private java.lang.String[] paramNames
The names of parameters to the parent method, if debugging was enabled during compilation.- See Also:
LOCAL_VARIABLE_TABLE
-
attributes
private java.util.List<AttributeInfo> attributes
Attributes of thisCodeattribute.
-
LINE_NUMBER_TABLE
private static final java.lang.String LINE_NUMBER_TABLE
- See Also:
- Constant Field Values
-
LOCAL_VARIABLE_TABLE
private static final java.lang.String LOCAL_VARIABLE_TABLE
- See Also:
- Constant Field Values
-
LOCAL_VARIABLE_TYPE_TABLE
private static final java.lang.String LOCAL_VARIABLE_TYPE_TABLE
- See Also:
- Constant Field Values
-
STACK_MAP_TABLE
private static final java.lang.String STACK_MAP_TABLE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Code
public Code(MethodInfo mi)
Constructor.- Parameters:
mi- Information on the parent method.
-
-
Method Detail
-
getCodeLength
public int getCodeLength()
Returns the length of the code array, in bytes.- Returns:
- The length of the code array.
-
getMaxLocals
public int getMaxLocals()
Returns the number of local variables in the local variable array allocated upon invocation of this method, including the local variables used to pass parameters to the method on invocation.The greatest local variable index for a value of type
longordoubleismaxLocals-2. The greatest local variable index for a value of any other type ismaxLocals-1.- Returns:
- the maximum size of the local variable array.
-
getMaxStack
public int getMaxStack()
Returns the maximum depth of the operand stack of this method at any point during its execution.- Returns:
- The maximum value of the operand stack.
-
getMethodInfo
public MethodInfo getMethodInfo()
Returns the method containing this code.- Returns:
- The method containing this code.
-
getParameterName
public java.lang.String getParameterName(int index)
If debugging was enabled during compilation, this method returns the name of the given parameter to this method. Otherwise,nullis returned.- Parameters:
index- The index of the parameter.- Returns:
- The name of the parameter, or
null.
-
read
public static Code read(MethodInfo mi, java.io.DataInputStream in) throws java.io.IOException
Reads aCodeattribute from an input stream.- Parameters:
mi- The parent method.in- The input stream.- Returns:
- The
Codeattribute. - Throws:
java.io.IOException- If an IO error occurs.
-
readAttribute
private AttributeInfo readAttribute(java.io.DataInputStream in) throws java.io.IOException
Reads an attribute for thisCodeattribute from an input stream.- Parameters:
in- The input stream to read from.- Returns:
- The attribute read.
- Throws:
java.io.IOException- If an IO error occurs.
-
-