|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectwt.loader.ClassFile
This class is used to manipulate Java class files in strange and mysterious ways. Usage it typically to feed it an array of bytes that are a class file, manipulate the class, then convert the class back into bytes, and feed the final result to defineClass().
AttributeInfo
,
ConstantPoolInfo
,
MethodInfo
,
FieldInfo
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
|
static int |
ACC_STATIC
|
static int |
ACC_SYNCHRONIZED
|
static int |
ACC_THREADSAFE
|
static int |
ACC_TRANSIENT
|
(package private) short |
accessFlags
|
(package private) AttributeInfo[] |
attributes
|
(package private) ConstantPoolInfo[] |
constantPool
|
boolean |
debug
|
boolean |
dumpConstants
|
(package private) FieldInfo[] |
fields
|
(package private) ConstantPoolInfo[] |
interfaces
|
(package private) boolean |
isValidClass
|
(package private) int |
magic
|
(package private) short |
majorVersion
|
(package private) MethodInfo[] |
methods
|
(package private) short |
minorVersion
|
(package private) ConstantPoolInfo |
superClass
|
(package private) ConstantPoolInfo |
thisClass
|
private static String |
versionID
|
Constructor Summary | |
ClassFile()
|
Method Summary | |
static String |
accessString(short flags)
Returns a string that represents what the access flags are set for. |
void |
addAttribute(AttributeInfo newAttribute)
Add a new optional class Attribute. |
short |
addConstantPoolItem(ConstantPoolInfo item)
Add a single constant pool item and return its index. |
void |
addConstantPoolItems(ConstantPoolInfo[] items)
Add some items to the constant pool. |
void |
deleteMethod(String name,
String signature)
Delete a named method from this class. |
void |
display(PrintStream ps)
Write out a text version of this class. |
AttributeInfo |
getAttribute(String name)
Return the attribute named 'name' from the class file. |
String |
getClassName()
|
ConstantPoolInfo |
getConstantPoolItem(short index)
Return a constant pool item from this class. |
ConstantPoolInfo |
getConstantRef(short index)
|
void |
mapClass(String oldClass,
String newClass)
Map occurences of class oldClass to occurrences of class newClass. |
void |
mapPackage(String oldPackage,
String newPackage)
Map occurences of package oldPackage to package newPackage. |
static String |
nextSig(String sig)
Returns the next signature from a string of concatenated signatures. |
private String |
printClassName(String s)
Print the name of a class in "canonical form" |
boolean |
read(InputStream in)
Read a class from InputStream in. |
String |
toString()
The boring version of display(). |
static String |
typeString(String typeString,
String varName)
Takes a type signature and a string representing a variable name and returns a declaration for that variable name. |
void |
write(OutputStream out)
Write the class out as a stream of bytes to the output stream. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private static final String versionID
int magic
short majorVersion
short minorVersion
ConstantPoolInfo[] constantPool
short accessFlags
ConstantPoolInfo thisClass
ConstantPoolInfo superClass
ConstantPoolInfo[] interfaces
FieldInfo[] fields
MethodInfo[] methods
AttributeInfo[] attributes
boolean isValidClass
public static final int ACC_PUBLIC
public static final int ACC_PRIVATE
public static final int ACC_PROTECTED
public static final int ACC_STATIC
public static final int ACC_FINAL
public static final int ACC_SYNCHRONIZED
public static final int ACC_THREADSAFE
public static final int ACC_TRANSIENT
public static final int ACC_NATIVE
public static final int ACC_INTERFACE
public static final int ACC_ABSTRACT
public boolean debug
public boolean dumpConstants
Constructor Detail |
public ClassFile()
Method Detail |
public boolean read(InputStream in) throws IOException
IOException
public void write(OutputStream out) throws IOException, Exception
IOException
Exception
public static String accessString(short flags)
public static String typeString(String typeString, String varName)
public static String nextSig(String sig)
private String printClassName(String s)
public String getClassName()
public String toString()
public void display(PrintStream ps) throws Exception
Exception
public ConstantPoolInfo getConstantRef(short index)
public short addConstantPoolItem(ConstantPoolInfo item) throws Exception
Exception
public void addConstantPoolItems(ConstantPoolInfo[] items)
public void addAttribute(AttributeInfo newAttribute)
public AttributeInfo getAttribute(String name)
public ConstantPoolInfo getConstantPoolItem(short index) throws Exception
Exception
public void mapClass(String oldClass, String newClass)
public void mapPackage(String oldPackage, String newPackage)
public void deleteMethod(String name, String signature)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |