|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--futils.utils.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
|
boolean |
debug
|
boolean |
dumpConstants
|
Constructor Summary | |
ClassFile()
|
Method Summary | |
static java.lang.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(java.lang.String name,
java.lang.String signature)
Delete a named method from this class. |
void |
display(java.io.PrintStream ps)
Write out a text version of this class. |
AttributeInfo |
getAttribute(java.lang.String name)
Return the attribute named 'name' from the class file. |
java.lang.String |
getClassName()
|
ConstantPoolInfo |
getConstantPoolItem(short index)
Return a constant pool item from this class. |
ConstantPoolInfo |
getConstantRef(short index)
|
void |
mapClass(java.lang.String oldClass,
java.lang.String newClass)
Map occurences of class oldClass to occurrences of class newClass. |
void |
mapPackage(java.lang.String oldPackage,
java.lang.String newPackage)
Map occurences of package oldPackage to package newPackage. |
static java.lang.String |
nextSig(java.lang.String sig)
Returns the next signature from a string of concatenated signatures. |
boolean |
read(java.io.InputStream in)
Read a class from InputStream in. |
java.lang.String |
toString()
The boring version of display(). |
static java.lang.String |
typeString(java.lang.String typeString,
java.lang.String varName)
Takes a type signature and a string representing a variable name and returns a declaration for that variable name. |
void |
write(java.io.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 |
public static final int ACC_ABSTRACT
public static final int ACC_FINAL
public static final int ACC_INTERFACE
public static final int ACC_NATIVE
public static final int ACC_PRIVATE
public static final int ACC_PROTECTED
public static final int ACC_PUBLIC
public static final int ACC_STATIC
public static final int ACC_SYNCHRONIZED
public static final int ACC_THREADSAFE
public static final int ACC_TRANSIENT
public boolean debug
public boolean dumpConstants
Constructor Detail |
public ClassFile()
Method Detail |
public static java.lang.String accessString(short flags)
public void addAttribute(AttributeInfo newAttribute)
public short addConstantPoolItem(ConstantPoolInfo item) throws java.lang.Exception
public void addConstantPoolItems(ConstantPoolInfo[] items)
public void deleteMethod(java.lang.String name, java.lang.String signature)
public void display(java.io.PrintStream ps) throws java.lang.Exception
public AttributeInfo getAttribute(java.lang.String name)
public java.lang.String getClassName()
public ConstantPoolInfo getConstantPoolItem(short index) throws java.lang.Exception
public ConstantPoolInfo getConstantRef(short index)
public void mapClass(java.lang.String oldClass, java.lang.String newClass)
public void mapPackage(java.lang.String oldPackage, java.lang.String newPackage)
public static java.lang.String nextSig(java.lang.String sig)
public boolean read(java.io.InputStream in) throws java.io.IOException
public java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String typeString(java.lang.String typeString, java.lang.String varName)
public void write(java.io.OutputStream out) throws java.io.IOException, java.lang.Exception
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |