|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectclassUtils.dumper.ClassFile
public class 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().
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 |
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()
Write out a text version of this class. |
AttributeInfo |
getAttribute(java.lang.String name)
Return the attribute named 'name' from the class file. |
static ClassFile |
getClassFile()
|
static ClassFile |
getClassFile(java.io.File f)
|
static ClassFile |
getClassFile(java.io.FileInputStream fis)
|
static ClassFile[] |
getClassFiles()
|
java.lang.String |
getClassName()
|
ConstantPoolInfo |
getConstantPoolItem(short index)
Return a constant pool item from this class. |
ConstantPoolInfo |
getConstantRef(short index)
|
boolean |
hasMainMethod()
|
static void |
main(java.lang.String[] args)
|
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. |
static ClassFile |
readClassFile(java.io.InputStream fis)
|
static void |
testGetClassFiles()
|
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 |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
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 dumpConstants
Constructor Detail |
---|
public ClassFile()
Method Detail |
---|
public boolean read(java.io.InputStream in) throws java.io.IOException
java.io.IOException
public void write(java.io.OutputStream out) throws java.io.IOException, java.lang.Exception
java.io.IOException
java.lang.Exception
public static java.lang.String accessString(short flags)
public static java.lang.String typeString(java.lang.String typeString, java.lang.String varName)
public static java.lang.String nextSig(java.lang.String sig)
public java.lang.String getClassName()
public java.lang.String toString()
toString
in class java.lang.Object
public void display() throws java.lang.Exception
java.lang.Exception
public ConstantPoolInfo getConstantRef(short index)
public short addConstantPoolItem(ConstantPoolInfo item) throws java.lang.Exception
java.lang.Exception
public void addConstantPoolItems(ConstantPoolInfo[] items)
public void addAttribute(AttributeInfo newAttribute)
public AttributeInfo getAttribute(java.lang.String name)
public ConstantPoolInfo getConstantPoolItem(short index) throws java.lang.Exception
java.lang.Exception
public void mapClass(java.lang.String oldClass, java.lang.String newClass)
public void mapPackage(java.lang.String oldPackage, java.lang.String newPackage)
public void deleteMethod(java.lang.String name, java.lang.String signature)
public static void testGetClassFiles()
public static ClassFile[] getClassFiles()
public static ClassFile getClassFile()
public static ClassFile getClassFile(java.io.File f)
public static ClassFile getClassFile(java.io.FileInputStream fis)
public static ClassFile readClassFile(java.io.InputStream fis) throws java.lang.Exception
java.lang.Exception
public boolean hasMainMethod()
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |