Fields Summary |
---|
private static final int | OBJECT_SUPER_CLASS_IDNumeric ID of java.lang.Object's super class |
final byte | TYPE_TAG_ARRAYTag type from VMConstants.java |
private String | baseNamebase name of class |
private String | classNameclassName of this class |
private String | classSignaturename of the class file this represents |
private FileReference | classFilesignature of this class name |
private int | magicidentifies class file format, always 0xCAFEBABE |
private int | majorVersionversion number of the class file |
private int | minorVersion |
private int | constantPoolCountnumber of items in the constant pool |
private ConstantPoolInfo[] | constantPoolarray of items in the constant pool |
private AccessFlags | accessFlagsaccess flags of this class |
private int | thisClassname of this class |
private int | superClassname of super class |
private int | interfacesCountnumber of interfaces this class implements |
private int[] | interfacesarray of indices into the constant pool table that
contain the names of the interfaces this class
implements |
private int | fieldsCountnumber of fields of this class |
private FieldInfo[] | fieldInfoarray of FieldInfo objects containing information
about all the fields of this class |
private int | methodsCountnumber of methods of this class |
private MethodInfo[] | methodInfoarray of MethodInfo objects containing information
about all the methods of this class |
private int | attributesCountnumber of attributes of this class |
private AttributeInfo[] | attributesattributes of this class |
private byte | typeTagJDWP type type tag |
int | classIDthe class ID of this class as told to us by the KVM itself |
int | classStatus |
Methods Summary |
---|
public boolean | equals(java.lang.String newclassName)
return className.equals(newclassName);
|
public java.util.List | getAllFieldInfo()Returns a list of FieldInfo objects
Vector vector = new Vector();
for ( int i=0; i < fieldInfo.length; i++ )
vector.add( fieldInfo[ i ] );
return vector;
|
public java.util.List | getAllInterfaces()Returns a list of class names that are interfaces implemented by
this class
Vector vector = new Vector();
int nameIndex;
ConstantUtf8Info utf8Info;
for ( int i=0; i < interfacesCount; i++ ) {
nameIndex =
((ConstantClassInfo)constantPool[interfaces[ i ]]).getNameIndex();
utf8Info = (ConstantUtf8Info)constantPool[nameIndex];
Log.LOGN(3, "interface: " + utf8Info.toString());
vector.add(utf8Info.toString());
}
return vector;
|
public java.util.List | getAllMethodInfo()Returns a list of MethodInfo objects
Vector vector = new Vector();
for ( int i=0; i < methodInfo.length; i++ )
vector.add( methodInfo[ i ] );
return vector;
|
public java.lang.String | getBaseName()
return baseName;
|
public java.lang.String | getClassFileName()Returns the class filename
return (classFile.toString());
|
public int | getClassID()
return (classID);
|
public java.lang.String | getClassName()
return className;
|
public java.lang.String | getClassSignature()
return classSignature;
|
public int | getClassStatus()
return (classStatus);
|
public byte | getJDWPTypeTag()
return typeTag;
|
public MethodInfo | getMethodInfoByIndex(int methodIndex)Get a methodinfo given a method index
if (methodIndex > methodInfo.length)
return null;
else return methodInfo[methodIndex];
|
public MethodInfo | getMethodInfoByName(java.lang.String methodName, java.lang.String sig)Get a methodinfo given a method name
for (int i = 0; i < methodsCount; i++) {
if ( methodInfo[i].getName().equals(methodName)
&& methodInfo[i].getSignatureRaw().equals( sig ) )
return methodInfo[i];
}
return null;
|
public int | getRawAccessFlags()
return (accessFlags.getRawAccessFlags());
|
public SourceFileAttribute | getSourceAttribute()Retrieves the Sourcefile attribute for this method.
int attrIndex = 0;
boolean found = false;
//loop through the attributes until the Source attribute is found or
//there are no attributes left
while ((!found) && (attrIndex < attributesCount))
{
if (attributes[attrIndex].getType () == AttributeInfo.ATTR_SOURCEFILE)
found = true;
else
++attrIndex;
}
if (found)
{//found the SourceFile attribute so return it
AttributeInfo attrInfo = attributes[attrIndex];
return (SourceFileAttribute) attrInfo.getInfo ();
}
else
return null; //didn't find it... just return null
|
public java.lang.String | getSuperClass()
if (superClass == OBJECT_SUPER_CLASS_ID)
return ("");
else {
ConstantClassInfo c = (ConstantClassInfo) constantPool[superClass];
int nameIndex = c.getNameIndex ();
ConstantUtf8Info utf8Info = (ConstantUtf8Info) constantPool[nameIndex];
return utf8Info.toString();
}
|
public java.util.List | getVariableTableForMethodIndex(int methodIndex)
MethodInfo mi = null;
int i = 0;
int attributeCount = 0;
List list = null;
if( (mi = getMethodInfoByIndex(methodIndex)) != null ){
list = mi.getLocalVariables();
// DEBUG
// if (list != null) {
// for( i = 0; i < list.size();i++)
// ((LocalVariable)list.get(i)).print();
// }
// END DEBUG
}
return list;
|
public MethodInfo | lookUpMethodByLineNumber(int lineNumber)Finds the method that contains the line in the source file with the
specified line number.
boolean found = false;
int index = 0;
//loop through all the methods until we find it or run out of methods
while ((!found) && (index < methodsCount))
{
if (methodInfo[index].containsLine (lineNumber))
found = true;
else
++index;
}
return (found) ? methodInfo[index] : null;
|
public void | print(java.io.PrintStream out)Print the contents of this class file in a nice easy to
read manner to the specified PrintStream
ConstantClassInfo c;
int nameIndex;
ConstantUtf8Info utf8Info;
//output the access flags
out.println (accessFlags);
//get the name of this class out of the constant pool table
//and output it
c = (ConstantClassInfo) constantPool[thisClass];
nameIndex = c.getNameIndex ();
utf8Info = (ConstantUtf8Info) constantPool[nameIndex];
out.println ("This Class:\t\t" + StringParser.parseClassName (utf8Info.toString ()));
//get the name of the super class out of the constant pool
//table and output it
String sc = getSuperClass();
out.print("Superclass: ");
if (sc.equals(""))
out.println("None");
else
out.println(sc);
//if this class implements any interfaces look them up in
//the constant pool table and output them
if (interfacesCount > 0)
for (int lcv = 0; lcv < interfacesCount; ++lcv)
{
c = (ConstantClassInfo) constantPool[interfaces[lcv]];
nameIndex = c.getNameIndex ();
utf8Info = (ConstantUtf8Info) constantPool[nameIndex];
out.println ("Interfaces:\t\t" + StringParser.parseClassName (utf8Info.toString ()));
}
//output the fields of this class file
for (int lcv = 0; lcv < fieldsCount; ++lcv)
out.println (fieldInfo[lcv].toString ());
//output the methods of this class file
for (int lcv = 0; lcv < methodsCount; ++lcv)
out.println (methodInfo[lcv].toString ());
//output the attributes of this class file
for (int lcv = 0; lcv < attributesCount; ++lcv)
out.println (attributes[lcv].toString ());
|
private int | readAttributes(java.io.DataInputStream iStream)Read in the attributes of this class.
//read in the number of attributes
attributesCount = iStream.readUnsignedShort ();
//allocate space for the attributes and read them in
attributes = new AttributeInfo[attributesCount];
for (int lcv=0; lcv < attributesCount; ++lcv)
attributes[lcv] = new AttributeInfo (iStream, constantPool);
return attributesCount;
|
public void | readClassFile()Reads a Java class file from the filename passed to the constructor.
DataInputStream iStream;
try
{
//create the data input stream and start reading in the
//class file
iStream = new DataInputStream (classFile.getInputStream());
magic = iStream.readInt ();
minorVersion = iStream.readUnsignedShort ();
majorVersion = iStream.readUnsignedShort ();
readConstantPool (iStream);
accessFlags = new AccessFlags (iStream);
thisClass = iStream.readUnsignedShort ();
superClass = iStream.readUnsignedShort ();
readInterfaces (iStream);
readFieldInfo (iStream);
readMethodInfo (iStream);
readAttributes (iStream);
iStream.close ();
}
catch (IOException e)
{//something bad happened with the IO.
System.out.println ("Caught IO Exception - " + e.getMessage ());
throw(e);
}
|
private int | readConstantPool(java.io.DataInputStream iStream)Reads in the constant pool from a Java class file.
//read the number of items in the constant pool
constantPoolCount = iStream.readUnsignedShort ();
//allocate space for the constant pool
constantPool = new ConstantPoolInfo[constantPoolCount];
//read in all the items of the constant pool
for (int lcv=1; lcv < constantPoolCount; ++lcv)
{
//the tag identifies what type of constant pool item
//this is so read it in, then branch and create the
//appropriate object
byte tag = iStream.readByte ();
switch (tag)
{
case ConstantPoolInfo.CONSTANT_Class :
constantPool[lcv] = new ConstantClassInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Fieldref :
constantPool[lcv] = new ConstantFieldrefInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Methodref :
constantPool[lcv] = new ConstantMethodrefInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_InterfaceMethodref :
constantPool[lcv] = new ConstantInterfaceMethodrefInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_String :
constantPool[lcv] = new ConstantStringInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Integer :
constantPool[lcv] = new ConstantIntegerInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Float :
constantPool[lcv] = new ConstantFloatInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Long :
constantPool[lcv] = new ConstantLongInfo (iStream);
++lcv; //longs "take" two constant pool entries
break;
case ConstantPoolInfo.CONSTANT_Double :
constantPool[lcv] = new ConstantDoubleInfo (iStream);
++lcv; //doubles "take" two constant pool entries
break;
case ConstantPoolInfo.CONSTANT_NameAndType :
constantPool[lcv] = new ConstantNameAndTypeInfo (iStream);
break;
case ConstantPoolInfo.CONSTANT_Utf8 :
constantPool[lcv] = new ConstantUtf8Info (iStream);
break;
default :
break;
}
}
return constantPoolCount;
|
private int | readFieldInfo(java.io.DataInputStream iStream)Read in the fields of this class.
//read in the number of fields
fieldsCount = iStream.readUnsignedShort ();
//allocate space for the fields and read them in
fieldInfo = new FieldInfo[fieldsCount];
for (int lcv=0; lcv < fieldsCount; ++lcv)
fieldInfo[lcv] = new FieldInfo (iStream, constantPool);
return fieldsCount;
|
private int | readInterfaces(java.io.DataInputStream iStream)Read in the interfaces from the class file.
interfacesCount = iStream.readUnsignedShort ();
//if there are no interfaces just return
if (interfacesCount == 0)
return interfacesCount;
//allocate space for the interfaces and read them in
interfaces = new int[interfacesCount];
for (int lcv=0; lcv < interfacesCount; ++lcv)
interfaces[lcv] = iStream.readUnsignedShort ();
return interfacesCount;
|
private int | readMethodInfo(java.io.DataInputStream iStream)Read in the methods of this class.
//read in the number of methods
methodsCount = iStream.readUnsignedShort ();
//allocate space for the methods and read them in
methodInfo = new MethodInfo[methodsCount];
for (int lcv=0; lcv < methodsCount; ++lcv)
methodInfo[lcv] = new MethodInfo (iStream, constantPool);
return methodsCount;
|
public void | setClassID(int classID)
this.classID = classID;
|
public void | setClassStatus(int status)
this.classStatus = status;
|