Class OfflineInstrumenter
java.lang.Object
com.ibm.wala.shrike.shrikeBT.tools.OfflineInstrumenterBase
com.ibm.wala.shrike.shrikeBT.shrikeCT.OfflineInstrumenter
This class provides a convenient way to iterate through a collection of Java classes and
instrument their code. This is just a specialization of OfflineInstrumenterBase to use the
shrikeCT functionality.
-
Nested Class Summary
Nested classes/interfaces inherited from class OfflineInstrumenterBase
OfflineInstrumenterBase.ManifestBuilderModifier and TypeClassDescriptionstatic interfaceThiscallback is notified whenever an entry has been added to the output zip file. -
Field Summary
Fields inherited from class OfflineInstrumenterBase
cha -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetClassName(Object cl) protected ObjectmakeClassFromStream(String inputName, BufferedInputStream s) Get the next class to be instrumented.voidUpdate the original class with some method changes.voidoutputModifiedClass(ClassInstrumenter out, ClassWriter code) Update the original class with some method changes.protected voidwriteClassTo(Object cl, Object mods, OutputStream s) Methods inherited from class OfflineInstrumenterBase
addInputClass, addInputDirectory, addInputElement, addInputJar, addInputJarEntry, addOutputJarEntry, beginTraversal, close, copyStream, endOutputJarEntry, getLastClassResourceName, getNumInputClasses, getOutputFile, internalNextClass, internalOutputModifiedClass, parseStandardArgs, setClassHierarchyProvider, setIgnore, setJARComment, setManifestBuilder, setOutputJar, setPassUnmodifiedClasses, writeUnmodifiedClassesModifier and TypeMethodDescriptionfinal voidaddInputClass(File baseDirectory, File f) Add a class file containing a source class to instrument.final voidaddInputDirectory(File baseDirectory, File d) Add a directory containing class files to instrument.final booleanaddInputElement(File baseDirectory, String a) Add something to instrument --- the name of a JAR file, a class file, a directory or an entry within a jar file (as filename#entryname).final voidaddInputJar(File f) Add a JAR file containing source classes to instrument.final voidaddInputJarEntry(File f, String name) Add a JAR entry containing a source class to instrument.final OutputStreamAdd a raw ZipEntry to the output JAR.final voidStart traversing the source class list from the beginning.final voidclose()Call this when you're done modifying classes.static voidcopyStream(InputStream in, OutputStream out) final voidComplete and flush the entry initiated by addOutputJarEntry.final StringGet the name of the resource containing the last class returned.final intfinal FileReturns the File we are storing classes into.protected final Objectprotected final booleaninternalOutputModifiedClass(Object cf, String name, Object mods) final String[]parseStandardArgs(String[] args) Parse an argument list to find elements to instrument and the name of the output file.voidfinal voidSkip the last class returned in every future traversal of the class list.final voidsetJARComment(String comment) Set the JAR Comment for the output JAR.voidThis installs a ManifestBuilder callback that this class will notify whenever an entry has been added to the output zip file.final voidsetOutputJar(File f) Set the file in which instrumented classes will be deposited.final voidsetPassUnmodifiedClasses(boolean pass) Indicate whether classes which are not modified will be put into the output jar anyway.final voidCall this to copy any unmodified classes to the output.
-
Constructor Details
-
OfflineInstrumenter
public OfflineInstrumenter()
-
-
Method Details
-
makeClassFromStream
- Specified by:
makeClassFromStreamin classOfflineInstrumenterBase- Throws:
IOException
-
getClassName
- Specified by:
getClassNamein classOfflineInstrumenterBase
-
writeClassTo
- Specified by:
writeClassToin classOfflineInstrumenterBase- Throws:
IOException
-
nextClass
Get the next class to be instrumented.- Throws:
IOException
-
outputModifiedClass
public void outputModifiedClass(ClassInstrumenter out, ClassWriter code) throws IllegalStateException, IOException Update the original class with some method changes. 'code' should be the result of out.emitClass(). You can add new fields and methods to 'code' (or make other changes) before calling this method.- Throws:
IllegalStateExceptionIOException
-
outputModifiedClass
Update the original class with some method changes. This method calls out.emitClass() for you.- Throws:
IllegalArgumentExceptionIOException
-