scale.jcr
Class ClassFile

java.lang.Object
  extended by scale.jcr.ClassFile

public class ClassFile
extends java.lang.Object

This class is used to both represent a Java class file and to read that class file.

$Id: ClassFile.java,v 1.15 2007-10-04 19:58:15 burrill Exp $

Copyright 2008 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.


Field Summary
static int ACC_ABSTRACT
           
static int ACC_FINAL
           
static int ACC_INTERFACE
           
static int ACC_NATIVE
           
static int ACC_PRIVATE
           
static int ACC_PROTECTED
           
static int ACC_PUBLIC
          The access masks.
static int ACC_STATIC
           
static int ACC_SUPER
           
static int ACC_SYNCHRONIZED
           
static int ACC_TRANSIENT
           
static int ACC_VOLATILE
           
static int classesRead
          A running counter of the number of Java class files read.
 
Constructor Summary
ClassFile(java.lang.String name)
          Read in the specified Java class file.
 
Method Summary
 void addRefClasses(Stack<java.lang.String> wl)
          Adds all the class names referenced by this class to the stack.
static void closeZipFiles()
          Closes any zip or jar files opened to read any class.
 int getAccessFlags()
          Return the accessFlags field of the class file.
 AttributeInfo getAttribute(int index)
          Return the attribute entry specified.
 AttributeInfo[] getAttributes()
          Return an array of the AttributeInfo structures for the class.
 CPInfo getCP(int index)
          Return the constant pool entry specified.
 FieldInfo getField(int index)
          Return the field entry specified.
 FieldInfo[] getFields()
          Return an array of the FieldInfo structures for the class.
 int getInterface(int index)
          Return the interface index specified.
 int[] getInterfaces()
          Return an array of interface indexs into the constant pool.
 int getMagic()
          Return the magic field of the class file.
 int getMajorVersion()
          Return the majorVersion field of the class file.
 MethodInfo getMethod(int index)
          Return the method entry specified.
 MethodInfo[] getMethods()
          Return an array of the MethodInfo structures for the class.
 int getMinorVersion()
          Return the minorVersion field of the class file.
 java.lang.String getName(int index)
          Return the name of entry in the constant pool.
 java.lang.String getString(int index)
          Return the String from the constant pool.
 int getSuperClass()
          Return the superClass field of the class file.
 int getThisClass()
          Return the thisClass field of the class file.
 int numCPEntries()
          Return the number of constant pool entries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACC_PUBLIC

public static final int ACC_PUBLIC
The access masks.

See Also:
Constant Field Values

ACC_PRIVATE

public static final int ACC_PRIVATE
See Also:
Constant Field Values

ACC_PROTECTED

public static final int ACC_PROTECTED
See Also:
Constant Field Values

ACC_STATIC

public static final int ACC_STATIC
See Also:
Constant Field Values

ACC_FINAL

public static final int ACC_FINAL
See Also:
Constant Field Values

ACC_SUPER

public static final int ACC_SUPER
See Also:
Constant Field Values

ACC_SYNCHRONIZED

public static final int ACC_SYNCHRONIZED
See Also:
Constant Field Values

ACC_VOLATILE

public static final int ACC_VOLATILE
See Also:
Constant Field Values

ACC_TRANSIENT

public static final int ACC_TRANSIENT
See Also:
Constant Field Values

ACC_NATIVE

public static final int ACC_NATIVE
See Also:
Constant Field Values

ACC_INTERFACE

public static final int ACC_INTERFACE
See Also:
Constant Field Values

ACC_ABSTRACT

public static final int ACC_ABSTRACT
See Also:
Constant Field Values

classesRead

public static int classesRead
A running counter of the number of Java class files read.

Constructor Detail

ClassFile

public ClassFile(java.lang.String name)
          throws InvalidException
Read in the specified Java class file.

Throws:
InvalidException - if the class file was not read successfully
Method Detail

getMagic

public int getMagic()
Return the magic field of the class file.


getMinorVersion

public int getMinorVersion()
Return the minorVersion field of the class file.


getMajorVersion

public int getMajorVersion()
Return the majorVersion field of the class file.


getAccessFlags

public int getAccessFlags()
Return the accessFlags field of the class file.


getThisClass

public int getThisClass()
Return the thisClass field of the class file.


getSuperClass

public int getSuperClass()
Return the superClass field of the class file.


numCPEntries

public int numCPEntries()
Return the number of constant pool entries.


getCP

public CPInfo getCP(int index)
Return the constant pool entry specified.


getName

public java.lang.String getName(int index)
Return the name of entry in the constant pool.

Parameters:
index - is an index into the constant pool of a Utf-8 string

getString

public java.lang.String getString(int index)
Return the String from the constant pool.

Parameters:
index - is an index into the constant pool of a Utf-8 string

getInterface

public int getInterface(int index)
Return the interface index specified.


getInterfaces

public int[] getInterfaces()
Return an array of interface indexs into the constant pool.


getField

public FieldInfo getField(int index)
Return the field entry specified.


getFields

public FieldInfo[] getFields()
Return an array of the FieldInfo structures for the class.


getMethod

public MethodInfo getMethod(int index)
Return the method entry specified.


getMethods

public MethodInfo[] getMethods()
Return an array of the MethodInfo structures for the class.


getAttribute

public AttributeInfo getAttribute(int index)
Return the attribute entry specified.


getAttributes

public AttributeInfo[] getAttributes()
Return an array of the AttributeInfo structures for the class.


addRefClasses

public void addRefClasses(Stack<java.lang.String> wl)
Adds all the class names referenced by this class to the stack.


closeZipFiles

public static void closeZipFiles()
Closes any zip or jar files opened to read any class.