|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.wala.shrikeBT.shrikeCT.ClassInstrumenter
public final class ClassInstrumenter
This class provides a convenient way to instrument every method in a class. It assumes you are using ShrikeCT to read and write classes. It's stateful; initially every method is set to the original code read from the class, but you can then go in and modify the methods.
| Nested Class Summary | |
|---|---|
static interface |
ClassInstrumenter.MethodExaminer
Implement this interface to instrument every method of a class using visitMethods() below. |
| Constructor Summary | |
|---|---|
ClassInstrumenter(byte[] bytes)
Create a class instrumenter from raw bytes. |
|
ClassInstrumenter(ClassReader cr)
Create a class instrumenter from a preinitialized class reader. |
|
| Method Summary | |
|---|---|
MethodData |
createEmptyMethodData(java.lang.String name,
java.lang.String sig,
int access)
|
void |
deleteMethod(int i)
Indicate that the method should be deleted from the class. |
ClassWriter |
emitClass()
Create a class which is a copy of the original class but with the new method code. |
void |
enableFakeLineNumbers(int offset)
Calling this means that methods without line numbers get fake line numbers added: each bytecode instruction is treated as at line 'offset' + the offset of the instruction. |
CodeReader |
getMethodCode(int i)
Get the original code resource for the method. |
ClassReader |
getReader()
|
boolean |
isChanged()
Check whether any methods in the class have actually been changed. |
void |
newMethod(MethodData md,
ClassWriter classWriter,
ClassWriter.Element rawLines)
|
void |
newMethod(java.lang.String name,
java.lang.String sig,
java.util.ArrayList<Instruction> instructions,
int access,
ClassWriter classWriter,
ClassWriter.Element rawLines)
Xiangyu |
void |
replaceMethod(int i,
MethodData md)
Replace the code for method i with new code. |
void |
resetMethod(int i)
Reset method i back to the code from the original class, and "undelete" it if it was marked for deletion. |
MethodData |
visitMethod(int i)
Get the current state of method i. |
void |
visitMethods(ClassInstrumenter.MethodExaminer me)
Do something to every method in the class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClassInstrumenter(byte[] bytes)
throws InvalidClassFileException
InvalidClassFileException
public ClassInstrumenter(ClassReader cr)
throws InvalidClassFileException
java.lang.IllegalArgumentException - if cr is null
InvalidClassFileException| Method Detail |
|---|
public void enableFakeLineNumbers(int offset)
public ClassReader getReader()
public void deleteMethod(int i)
i - the index of the method to delete
public MethodData createEmptyMethodData(java.lang.String name,
java.lang.String sig,
int access)
public void newMethod(java.lang.String name,
java.lang.String sig,
java.util.ArrayList<Instruction> instructions,
int access,
ClassWriter classWriter,
ClassWriter.Element rawLines)
java.lang.IllegalArgumentException - if classWriter is null
java.lang.IllegalArgumentException - if instructions is null
public void newMethod(MethodData md,
ClassWriter classWriter,
ClassWriter.Element rawLines)
public void visitMethods(ClassInstrumenter.MethodExaminer me)
throws InvalidClassFileException
me - the visitor to apply to each method
InvalidClassFileException
public MethodData visitMethod(int i)
throws InvalidClassFileException
i - the index of the method to inspect
InvalidClassFileException
public CodeReader getMethodCode(int i)
throws InvalidClassFileException
i - the index of the method to inspect
InvalidClassFileExceptionpublic void resetMethod(int i)
i - the index of the method to reset
public void replaceMethod(int i,
MethodData md)
i - the index of the method to replace
java.lang.IllegalArgumentException - if md is nullpublic boolean isChanged()
public ClassWriter emitClass()
throws InvalidClassFileException
InvalidClassFileException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||