Fields Summary |
---|
private static final int | ACC_PUBLICaccess flag if this method is public |
private static final int | ACC_PRIVATEaccess flag if this method is private |
private static final int | ACC_PROTECTEDaccess flag if this method is protected |
private static final int | ACC_STATICaccess flag if this method is static |
private static final int | ACC_FINALaccess flag if this method is final |
private static final int | ACC_SYNCHRONIZEDaccess flag if this method is synchronized |
private static final int | ACC_NATIVEaccess flag if this method is native |
private static final int | ACC_ABSTRACTaccess flag if this method is abstract |
private static final int | ACC_STRICTaccess flag if this method is strict |
private int | accessFlagsaccess flags of this method |
private int | nameIndexindex into constant pool containing name of method |
private int | descriptorIndexindex into constant pool table containing method signature |
private int | attributesCountnumber of attributes this method has |
private int | argCountnumber of arguments this method has |
private AttributeInfo[] | attributesarray of attributes for this method |
private ConstantPoolInfo[] | constantPoolreference to class file's constant pool |
Methods Summary |
---|
public boolean | containsLine(int lineNumber)Determine if this method contains the specified source file line number.
//get the code attribute
CodeAttribute code = getCodeAttribute ();
//look up if this line number is in the code attribute's LineNumberTable
if (code != null)
return (code.containsLine (lineNumber));
else
return false;
|
public java.lang.String | getAccess()Query the access permissions of this method.
String s = new String ("");
if ((accessFlags & ACC_PUBLIC) > 0)
s = s + "public ";
if ((accessFlags & ACC_PRIVATE) > 0)
s = s + "private ";
if ((accessFlags & ACC_PROTECTED) > 0)
s = s + "protected ";
if ((accessFlags & ACC_STATIC) > 0)
s = s + "static ";
if ((accessFlags & ACC_FINAL) > 0)
s = s + "final ";
if ((accessFlags & ACC_SYNCHRONIZED) > 0)
s = s + "synchronized ";
if ((accessFlags & ACC_NATIVE) > 0)
s = s + "native ";
if ((accessFlags & ACC_ABSTRACT) > 0)
s = s + "abstract ";
if ((accessFlags & ACC_STRICT) > 0)
s = s + "strict";
if (s.length () == 0)
s = "Not explicitly specified.";
return s;
|
public int | getAccessFlags()Obtain the access flags as an int
return accessFlags;
|
public int | getArgCount()
return (argCount);
|
public int[][] | getBreakableLineNumbers()Gets the source file line numbers and code array indices of all
lines in this method that a breakpoint can be set at.
//get this method's code array
CodeAttribute code = getCodeAttribute ();
if (code == null) {
// jpc
Log.LOGN(2, "code is null!");
return null;
}
//get the code array's line number table
LineNumberTableAttribute lines = code.getLineNumberTable ();
if (lines == null) {
// jpc
Log.LOGN(2, "lines is null!");
return null;
}
return (lines.getLineNumbersAndIndicesAsArray ());
|
public CodeAttribute | getCodeAttribute()Retrieves the Code attribute for this method.
int attrIndex = 0;
boolean found = false;
//loop through the attributes until the Code attribute is found or
//there are no attributes left
while ((!found) && (attrIndex < attributesCount))
{
if (attributes[attrIndex].getType () == AttributeInfo.ATTR_CODE)
found = true;
else
++attrIndex;
}
if (found)
{//found the Code attribute so return it
AttributeInfo attrInfo = attributes[attrIndex];
CodeAttribute code = (CodeAttribute) attrInfo.getInfo ();
return code;
}
else
return null; //didn't find it... just return null
|
public int | getCodeIndex(int lineNumber)Retrieves the starting index in the code array that equates to the
specified line number in the source file.
boolean found = false;
int index = 0;
//get the code attribute
CodeAttribute code = getCodeAttribute ();
if (code == null)
return -1;
//get the LineNumberTable for this method
LineNumberTableAttribute lines = code.getLineNumberTable ();
if (lines == null)
return -1;
//query the line number table for the code array index that
//contains the specified line number
return lines.getCodeIndexBySourceLineNumber (lineNumber);
|
public java.util.List | getLocalVariables()
AttributeInfo[] ai = null;
int attribCount = 0;
Attribute attribute = null;
for(int i = 0; i < attributesCount ; i++ ){
if( attributes[i].getType() == AttributeInfo.ATTR_CODE){
attribute = attributes[i].getInfo();
ai = ((CodeAttribute)attribute).getAttributes();
attribCount = ((CodeAttribute)attribute).getAttributeCount();
break;
}
}
int i = 0;
for(i = 0; i < attribCount ; i++ ){
if( ai[i].getType() == AttributeInfo.ATTR_LOCALVAR){
attribute = ai[i].getInfo();
LocalVariableTable[] localVariableTable =
((LocalVariableTableAttribute)attribute).getLocalVariableTable();
ConstantUtf8Info utf8Info;
List localVariableList = new ArrayList();
for ( i = 0; i < localVariableTable.length; ++i)
{
utf8Info = (ConstantUtf8Info)
constantPool[localVariableTable[i].nameIndex];
String name = utf8Info.toString ();
utf8Info = (ConstantUtf8Info)
constantPool[localVariableTable[i].descriptorIndex];
String type = StringParser.parseDataType (utf8Info.toString ());
localVariableList.add(
new LocalVariable( name,type, localVariableTable[i].startPC,
localVariableTable[i].length,localVariableTable[i].index));
}
return localVariableList;
}
}
// should not reach here
return null;
|
public java.lang.String | getName()Retrieve the name of this method.
ConstantUtf8Info utf8Info;
String methodName;
//look up the name in the constant pool
utf8Info = (ConstantUtf8Info) constantPool[nameIndex];
methodName = utf8Info.toString ();
return (methodName);
|
public java.util.LinkedList | getParameterList()Retrieve the parameter list of this method.
ConstantUtf8Info utf8Info;
String s = new String ("");
//look up the method signature in the constant pool
utf8Info = (ConstantUtf8Info) constantPool[descriptorIndex];
//parse the parameter list
LinkedList paramList = StringParser.getParametersAsLL (utf8Info.toString ());
return paramList;
|
public java.lang.String | getReturnValue()Query the return value of this method.
ConstantUtf8Info utf8Info;
//look up the return value in the constant pool
utf8Info = (ConstantUtf8Info) constantPool[descriptorIndex];
//convert the encoded return value into it's full form
return (StringParser.getReturnValue (utf8Info.toString ()));
|
public java.lang.String | getSignature()Retrieve the full signature (params and return value) of this method
ConstantUtf8Info utf8Info;
//look up the signature in the constant pool
utf8Info = (ConstantUtf8Info) constantPool[descriptorIndex];
//parse the encoded form into it's full form
return (StringParser.parseSignature (utf8Info.toString ()));
|
public java.lang.String | getSignatureRaw()Retrieve the full signature as specified in the class file
(params and return value) of this method
ConstantUtf8Info utf8Info;
//look up the signature in the constant pool
utf8Info = (ConstantUtf8Info) constantPool[descriptorIndex];
return (utf8Info.toString ());
|
public java.lang.String | toString()Formats information about this method in a nice easy to read
string.
String s = new String ("");
s = s + "Method:\n\tAccess Flags=\t";
s = s + getAccess ();
s = s + "\n\tName=\t\t";
s = s + getName ();
s = s + "\n\tSignature=\t";
s = s + getSignature ();
s = s + "\n\tRaw signature=\t";
s = s + getSignatureRaw();
for (int lcv = 0; lcv < attributesCount; ++lcv)
s = s + "\n\t" + attributes[lcv].toString ();
s = s + "\n\t BreakableLines=\t";
int list[][] = getBreakableLineNumbers();
if (list == null) {
s = s + "No breakable lines\n";
} else {
for( int i = 0; i< list.length; i++) {
s = s + "\tSourceLine: " + list[i][0] + " CodeIndex: " +
list[i][1] + "\n";
}
}
return s;
|