Multivalent API

phelps.lang.reflect
Class ClassFile

java.lang.Object
  extended by phelps.lang.reflect.ClassFile

public class ClassFile
extends java.lang.Object

.class file reflection that reports more complete information than java.lang.reflect.

The JavaTM Virtual Machine Specification, Second Edition
by Tim Lindholm and Frank Yellin

STATUS: Doesn't read method exception table, inner classes.

Related work: BIT: Bytecode Instrumenting Tool by Han Lee and Ben Zorn. They determined basic blocks, supported insertion of calls (only; not arbitrary code), and implemented write().

Version:
$Revision: 1.3 $ $Date: 2003/06/01 07:58:57 $
See Also:
java.lang.reflect

Field Summary
 short access_flags
           
 Attribute_info[] attributes
           
 ClassFile component
           
 Cp_info[] constant_pool
           
 int dimensions
           
 Field_info[] fields
           
 java.lang.String[] interfaces
           
static int MAGIC
           
 short major_version
           
 Method_info[] methods
           
 short minor_version
           
 java.lang.String pkg
           
 java.lang.String super_class
           
 java.lang.String this_class
           
 
Constructor Summary
ClassFile(byte[] bytes)
           
ClassFile(ClassFile component, int dimensions)
          For arrays.
ClassFile(java.io.File f)
           
ClassFile(java.io.InputStream is)
           
 
Method Summary
static java.lang.String access2String(int access)
           
static ClassFile forName(java.lang.String name)
           
 Attribute_info getAttribute(Attribute_info[] ai, java.lang.String name)
           
 Method_info[] getDeclaredMethods()
           
 int getModifiers()
           
 java.lang.String getName()
           
 java.lang.String getPackage()
           
 java.lang.String getSuperclass()
           
 boolean isArray()
           
 boolean isAssignableFrom(ClassFile subclass)
          Returns true if this class is a subclass of superclass.
 boolean isPrimitive()
           
protected  void load()
           
static void putPool(ClassFile cf)
          Add ClassFile to pool of known classes, for better isAssignableFrom().
static int sizeof(java.lang.String type)
          Don't know sizes of arrays and Objects statically.
 java.lang.String toString()
           
static java.lang.String type2String(java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAGIC

public static final int MAGIC
See Also:
Constant Field Values

minor_version

public short minor_version

major_version

public short major_version

constant_pool

public Cp_info[] constant_pool

access_flags

public short access_flags

this_class

public java.lang.String this_class

super_class

public java.lang.String super_class

interfaces

public java.lang.String[] interfaces

fields

public Field_info[] fields

methods

public Method_info[] methods

attributes

public Attribute_info[] attributes

component

public ClassFile component

dimensions

public int dimensions

pkg

public java.lang.String pkg
Constructor Detail

ClassFile

public ClassFile(ClassFile component,
                 int dimensions)
For arrays.


ClassFile

public ClassFile(java.io.File f)
          throws java.io.IOException
Throws:
java.io.IOException

ClassFile

public ClassFile(java.io.InputStream is)
          throws java.io.IOException
Throws:
java.io.IOException

ClassFile

public ClassFile(byte[] bytes)
Method Detail

load

protected void load()

getModifiers

public int getModifiers()

getSuperclass

public java.lang.String getSuperclass()

getName

public java.lang.String getName()

getPackage

public java.lang.String getPackage()

getDeclaredMethods

public Method_info[] getDeclaredMethods()

access2String

public static java.lang.String access2String(int access)

type2String

public static java.lang.String type2String(java.lang.String type)

sizeof

public static int sizeof(java.lang.String type)
Don't know sizes of arrays and Objects statically.


getAttribute

public Attribute_info getAttribute(Attribute_info[] ai,
                                   java.lang.String name)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

isAssignableFrom

public boolean isAssignableFrom(ClassFile subclass)
Returns true if this class is a subclass of superclass. Only knows about classes added with putPool(ClassFile).


isArray

public boolean isArray()

isPrimitive

public boolean isPrimitive()

forName

public static ClassFile forName(java.lang.String name)

putPool

public static void putPool(ClassFile cf)
Add ClassFile to pool of known classes, for better isAssignableFrom().


Multivalent API