phelps.lang.reflect

Class ClassFile

public class ClassFile extends 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
shortaccess_flags
Attribute_info[]attributes
ClassFilecomponent
Cp_info[]constant_pool
intdimensions
Field_info[]fields
String[]interfaces
static intMAGIC
shortmajor_version
Method_info[]methods
shortminor_version
Stringpkg
Stringsuper_class
Stringthis_class
Constructor Summary
ClassFile(ClassFile component, int dimensions)
For arrays.
ClassFile(File f)
ClassFile(InputStream is)
ClassFile(byte[] bytes)
Method Summary
static Stringaccess2String(int access)
static ClassFileforName(String name)
Attribute_infogetAttribute(Attribute_info[] ai, String name)
Method_info[]getDeclaredMethods()
intgetModifiers()
StringgetName()
StringgetPackage()
StringgetSuperclass()
booleanisArray()
booleanisAssignableFrom(ClassFile subclass)
Returns true if this class is a subclass of superclass.
booleanisPrimitive()
protected voidload()
static voidputPool(ClassFile cf)
Add ClassFile to pool of known classes, for better isAssignableFrom().
static intsizeof(String type)
Don't know sizes of arrays and Objects statically.
StringtoString()
static Stringtype2String(String type)

Field Detail

access_flags

public short access_flags

attributes

public Attribute_info[] attributes

component

public ClassFile component

constant_pool

public Cp_info[] constant_pool

dimensions

public int dimensions

fields

public Field_info[] fields

interfaces

public String[] interfaces

MAGIC

public static final int MAGIC

major_version

public short major_version

methods

public Method_info[] methods

minor_version

public short minor_version

pkg

public String pkg

super_class

public String super_class

this_class

public String this_class

Constructor Detail

ClassFile

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

ClassFile

public ClassFile(File f)

ClassFile

public ClassFile(InputStream is)

ClassFile

public ClassFile(byte[] bytes)

Method Detail

access2String

public static String access2String(int access)

forName

public static ClassFile forName(String name)

getAttribute

public Attribute_info getAttribute(Attribute_info[] ai, String name)

getDeclaredMethods

public Method_info[] getDeclaredMethods()

getModifiers

public int getModifiers()

getName

public String getName()

getPackage

public String getPackage()

getSuperclass

public String getSuperclass()

isArray

public boolean isArray()

isAssignableFrom

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

isPrimitive

public boolean isPrimitive()

load

protected void load()

putPool

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

sizeof

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

toString

public String toString()

type2String

public static String type2String(String type)