|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object sofya.ed.Instrumentor
public abstract class Instrumentor
Abstract base class for all instrumentors, which instrument Java class files for execution by an event dispatcher.
Special note regarding instrumentation of Sofya as a subject: If
you change the mode of instrumentation (compatible, normal optimized,
etc...) of the instrumentation applied to Sofya as a subject, make
sure to delete the 'bootstrap.jar' file in the inst
directory of the subject Sofya to force the event dispatcher to rebuild it
using the newly instrumented SocketProbe. Otherwise the event dispatcher may
refuse to run if the old mode of instrumentation that was applied to
SocketProbe in the jar file is not compatible with a form that
it accepts.
cfInstrumentor
,
SemanticInstrumentor
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.bcel.generic.InstructionConstants |
---|
org.apache.bcel.generic.InstructionConstants.Clinit |
Nested classes/interfaces inherited from interface sofya.base.SConstants |
---|
SConstants.BlockLabel, SConstants.BlockObjectType, SConstants.BlockSubType, SConstants.BlockType, SConstants.BranchObjectType, SConstants.BranchType, SConstants.EDObjectType, SConstants.TraceObjectType |
Field Summary | |
---|---|
protected int |
arrayVarref
Index to a local variable in the instrumented method used to hold the hit-object array (used by optimized normal and JUnit instrumentation). |
protected int |
blockCount
Number of blocks in the method currently referenced by instrumentation. |
protected CFHandler |
classGraphs
Handler for class method CFGs. |
protected boolean |
classHasMain
Flag indicating whether the class has a main method. |
protected boolean |
classHasStaticInit
Flag indicating whether the class has a static initializer ( <clinit> method). |
protected boolean |
classIsDispatcher
Flag indicating whether the class is an event dispatcher. |
protected boolean |
classIsSocketProbe
Flag indicating whether the class is SocketProbe. |
protected java.lang.String |
className
Name of the class currently loaded by the instrumentor, as provided in the constructor. |
protected org.apache.bcel.generic.ConstantPoolGen |
cpg
BCEL data structure representing the class constant pool. |
protected int |
excExitBooleanVar
Flag used to control whether the summary exit node will be marked on an exceptional exit. |
protected java.lang.String |
fullClassName
Fully qualified name of the class currently loaded by the instrumentor. |
protected java.util.Set |
handlerStarts
Cache of instruction handles that begin exception handlers, used by sequence instrumentation to guarantee that exceptional returns from calls will properly record the change in method to the trace. |
protected org.apache.bcel.generic.InstructionFactory |
iFactory
Factory object used to generate more complex instructions. |
protected java.lang.String |
instClassRef
Name of the class upon which instrumentation methods are to be invoked. |
protected int |
instMode
Integer code indicating type of instrumentation to be inserted. |
protected org.apache.bcel.classfile.JavaClass |
javaClass
BCEL data structure representing the class. |
protected org.apache.bcel.generic.ClassGen |
javaClassFile
BCEL data structure allowing more advanced modifications to class. |
protected java.lang.String |
lastInstrumented
Name of method last instrumented. |
protected CFG |
methodCFG
CFG for the method currently being instrumented. |
protected int |
methodEntryMethodref
Index to a method reference that should be called on entry to a new method, if any. |
protected org.apache.bcel.classfile.Method[] |
methods
Collection of uninstrumented methods in the class. |
protected java.lang.String |
mSignature
Signature of the method currently referenced by instrumentation. |
protected int |
port
Socket port to be used for instrumentation. |
protected boolean |
starterInserted
Flag indicating whether the call to SocketProbe.start has
been inserted. |
protected int |
startMethodref
Index to SocketProbe.start method reference added to
constant pool. |
protected java.lang.String |
tag
Tag associated with the class database files. |
protected boolean |
targetJUnit
Flag indicating that the instrumentation is targeted for a JUnit event dispatcher. |
protected int |
traceMethodref
Index to probe statement method reference added to constant pool. |
protected int |
typeFlags
Bit vector representing types of blocks that will be instrumented. |
protected boolean |
useDefaultPort
Flag indicating whether the port will be selected automatically. |
Fields inherited from interface org.apache.bcel.generic.InstructionConstants |
---|
AALOAD, AASTORE, ACONST_NULL, ALOAD_0, ALOAD_1, ALOAD_2, ARETURN, ARRAYLENGTH, ASTORE_0, ASTORE_1, ASTORE_2, ATHROW, BALOAD, BASTORE, bla, CALOAD, CASTORE, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DMUL, DNEG, DREM, DRETURN, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FMUL, FNEG, FREM, FRETURN, FSUB, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, ILOAD_0, ILOAD_1, ILOAD_2, IMUL, INEG, INSTRUCTIONS, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE_0, ISTORE_1, ISTORE_2, ISUB, IUSHR, IXOR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDIV, LMUL, LNEG, LOR, LREM, LRETURN, LSHL, LSHR, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, NOP, POP, POP2, RETURN, SALOAD, SASTORE, SWAP, THIS |
Fields inherited from interface sofya.base.SConstants |
---|
DEFAULT_PORT, INST_COMPATIBLE, INST_OLD_UNSUPPORTED, INST_OPT_NORMAL, INST_OPT_SEQUENCE, SIG_CHKALIVE, SIG_ECHO |
Constructor Summary | |
---|---|
protected |
Instrumentor()
Protected default constructor, to prevent unsafe instances of the instrumentor from being created. |
|
Instrumentor(java.lang.String[] argv)
Creates am instrumentor configured by a list of command line parameters. |
|
Instrumentor(java.lang.String className,
int typeFlags)
Creates an instrumentor for the specified class with the given object types activated for instrumentation and using the default port. |
|
Instrumentor(java.lang.String className,
int typeFlags,
int port)
Creates an instrumentor for the specified class with the given object types activated for instrumentation and using the given port. |
|
Instrumentor(java.lang.String className,
int typeFlags,
int port,
int instMode)
Creates an instrumentor for the specified class with the given object types activated for instrumentation, using the given port, and activating the specified mode of instrumentation. |
Method Summary | |
---|---|
protected void |
addDefaultHandler(org.apache.bcel.generic.MethodGen mg,
org.apache.bcel.generic.InstructionList il)
Modifies the main method, if necessary, to prevent
unhandled exceptions from being thrown. |
protected void |
cacheHandlerStarts(org.apache.bcel.generic.CodeExceptionGen[] excHandlers)
Reads the exception handlers associated with the method and caches the starting instruction handle for each handler. |
org.apache.bcel.classfile.JavaClass |
generateClass()
Gets the instrumented class. |
java.lang.String |
getClassName()
Gets the name of the class which is currently loaded in the instrumentor. |
int |
getInstMode()
Gets the form of instrumentation that the instrumentor is currently set to insert, which will be one of the following: SConstants.INST_COMPATIBLE
SConstants.INST_OPT_NORMAL
SConstants.INST_OPT_SEQUENCE
|
java.lang.String |
getLastInstrumented()
Gets the name of the last method instrumented. |
int |
getMethodCount()
Gets the number of methods in the class. |
java.lang.String |
getMethodName(int methodIndex)
Gets the name of a method in the class method array. |
java.lang.String |
getMethodSignature(int methodIndex)
Gets the signature of a method in the class method array, as a string. |
protected abstract SConstants.TraceObjectType |
getObjectType()
Gets the structural entity that is instrumented by this instrumentor. |
int |
getPort()
Gets the socket port being used for instrumentation. |
protected abstract java.lang.String |
getProbeClassName()
Gets the name of the class referenced by probes inserted by this instrumentor. |
java.lang.String |
getQualifiedName()
Gets the fully qualified name of the class (includes package name) which is currently loaded in the instrumentor. |
int |
getTypeFlags()
Gets the bit mask controlling the object types that are currently set to be instrumented by this instrumentor. |
boolean |
hasMain()
Reports whether the class has a main method. |
boolean |
hasStaticInit()
Reports whether the class has a static initializer. |
protected void |
init(int port)
Initializes the instrumentor, making it ready to instrument methods in the class. |
void |
insertFinisher(java.lang.String methodName,
org.apache.bcel.generic.Type returnType,
org.apache.bcel.generic.Type[] argumentTypes)
Inserts call to SocketProbe.finish unconditionally at
the exit points of the specified method. |
protected void |
insertProbeFinishCall(org.apache.bcel.generic.InstructionList il)
Inserts call to SocketProbe.finish()
immediately prior to any return instruction in the method. |
protected void |
insertProbeStartCall(org.apache.bcel.generic.InstructionList il)
Inserts call to SocketProbe.start(int,int,boolean,boolean,int)
at beginning of method. |
void |
insertStarter(java.lang.String methodName,
org.apache.bcel.generic.Type returnType,
org.apache.bcel.generic.Type[] argumentTypes)
Inserts call to SocketProbe.start unconditionally at
the beginning of the specified method. |
protected abstract org.apache.bcel.classfile.Method |
instrument(org.apache.bcel.classfile.Method m,
int methodIndex,
boolean insertStarter)
Instruments a method. |
void |
instrument(java.lang.String methodName,
org.apache.bcel.generic.Type returnType,
org.apache.bcel.generic.Type[] argumentTypes,
boolean insertStarter)
Instruments the method with the given name and signature using the current instrumentation settings. |
void |
instrumentAll()
Instruments every method in the class using the current instrumentation settings. |
protected void |
loadBlockRefs(Block[] blocks,
org.apache.bcel.generic.InstructionList il)
Loads the instruction handles corresponding to the bytecode offsets encoded in the given blocks into the reference fields for those blocks, using the supplied BCEL instruction list to find the handles. |
void |
loadClass(java.lang.String className)
Loads a new class into the instrumentor. |
void |
loadClass(java.lang.String className,
java.io.InputStream source)
Loads a new class into the instrumentor, from a given stream. |
protected void |
parseClass(java.lang.String className,
java.io.InputStream source)
Parses the class, making it ready for instrumentation. |
protected void |
parseCommandLine(java.lang.String[] argv)
Parses command line parameters that control aspects of the internal state of the instrumentor. |
protected abstract boolean |
parseTypeCodes(java.lang.String typeCodes)
Parses the command-line parameter that specifies the types of objects to be instrumented (eg '-BEXC', etc.). |
void |
reloadClass()
Reloads the current class from file, destroying any instrumentation that has been performed. |
void |
reloadMethod(java.lang.String methodName,
org.apache.bcel.generic.Type returnType,
org.apache.bcel.generic.Type[] argumentTypes)
Reloads a method, destroying any instrumentation previously applied to it. |
void |
setInstMode(int instMode)
Sets the form of instrumentation that the instrumentor is to insert. |
void |
setPort(int port,
boolean auto)
Sets the socket port to be used in instrumentation. |
abstract void |
setTypeFlags(int typeFlags)
Sets the bit mask controlling what object types are to be instrumented by this instrumentor. |
void |
writeClass(java.io.OutputStream dest)
Writes the binary instrumented class data to a stream. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected org.apache.bcel.classfile.JavaClass javaClass
protected org.apache.bcel.generic.ClassGen javaClassFile
protected org.apache.bcel.generic.ConstantPoolGen cpg
protected org.apache.bcel.classfile.Method[] methods
protected org.apache.bcel.generic.InstructionFactory iFactory
protected java.lang.String className
protected java.lang.String fullClassName
protected java.lang.String lastInstrumented
protected int port
protected boolean useDefaultPort
protected int typeFlags
protected int instMode
protected boolean targetJUnit
protected CFHandler classGraphs
protected java.lang.String tag
protected CFG methodCFG
protected java.lang.String instClassRef
protected boolean classIsDispatcher
protected boolean classIsSocketProbe
protected boolean classHasMain
main
method.
protected boolean classHasStaticInit
<clinit>
method).
protected boolean starterInserted
SocketProbe.start
has
been inserted.
protected int startMethodref
SocketProbe.start
method reference added to
constant pool.
protected int traceMethodref
protected int methodEntryMethodref
protected java.lang.String mSignature
protected int blockCount
protected int arrayVarref
protected int excExitBooleanVar
protected java.util.Set handlerStarts
Constructor Detail |
---|
protected Instrumentor()
public Instrumentor(java.lang.String[] argv) throws java.lang.IllegalArgumentException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
argv
- Set of command line parameters, such as would be obtained
from cfInstrumentor
.
java.lang.IllegalArgumentException
- If required parameters are missing,
invalid parameters are encountered, or data required for optional
parameters is missing.
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.public Instrumentor(java.lang.String className, int typeFlags) throws BadFileFormatException, java.lang.IllegalArgumentException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
className
- Name of the class to be instrumented.typeFlags
- Bit mask representing the types of objects to be
instrumented.
java.lang.IllegalArgumentException
- If required parameters are missing,
invalid parameters are encountered, or data required for optional
parameters is missing.
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.public Instrumentor(java.lang.String className, int typeFlags, int port) throws BadFileFormatException, java.lang.IllegalArgumentException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
className
- Name of the class to be instrumented.typeFlags
- Bit mask representing the types of objects to be
instrumented.port
- Port to which instrumentation should be set. The valid
range is 1024 to 65535.
java.lang.IllegalArgumentException
- If required parameters are missing,
invalid parameters are encountered, or data required for optional
parameters is missing.
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.public Instrumentor(java.lang.String className, int typeFlags, int port, int instMode) throws BadFileFormatException, java.lang.IllegalArgumentException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
className
- Name of the class to be instrumented.typeFlags
- Bit mask representing the types of objects to be
instrumented.port
- Port to which instrumentation should be set. The valid
range is 1024 to 65535.instMode
- Integer flag indicating the form of instrumentation to
be inserted. Acceptable values are the following:
java.lang.IllegalArgumentException
- If required parameters are missing,
invalid parameters are encountered, or data required for optional
parameters is missing.
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.Method Detail |
---|
protected void parseCommandLine(java.lang.String[] argv) throws java.lang.IllegalArgumentException
Note: Some parameters may need to be processed prior to
invocation of this method, such as is done by
cfInstrumentor
, to implement behaviors that should
not be reflected in the internal state of the instrumentor itself.
argv
- Command line parameters to be parsed.
java.lang.IllegalArgumentException
- If required parameters are missing,
invalid parameters are encountered, or data required for optional
parameters is missing.protected abstract boolean parseTypeCodes(java.lang.String typeCodes) throws java.lang.IllegalArgumentException
typeCodes
- Parameter read from command-line, including the
leading dash.
true
object types were read from the parameter,
false
if no types were given.
java.lang.IllegalArgumentException
- If an unrecognized object type
character is encountered.protected void parseClass(java.lang.String className, java.io.InputStream source) throws BadFileFormatException, java.io.IOException, java.lang.ClassFormatError
Uses BCEL to parse the class file and initialize the internal data structures used for inserting instrumentation.
className
- Name of the class to be parsed.source
- Stream from which the class should be parsed. May be
null
, in which case this method will attempt to load
the class from the classpath or the filesystem (in that order).
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.protected void init(int port) throws java.io.IOException
Analyzes the class and sets various flags used to control
instrumentation. Determines if the subject is a filter class
or SocketProbe
. Determines the default port
or checks that the port number is in range if one is specified. Adds
the instrumentation method references to the class constant pool.
Determines if the class has a static initializer and/or
main
method to control where to insert the call
to SocketProbe.start
.
port
- Port which is to be used for instrumentation. If a negative
number is supplied, the default port is selected. Otherwise, the valid
range for this parameter is 1024 to 65535.
java.io.IOException
public void loadClass(java.lang.String className) throws BadFileFormatException, java.io.FileNotFoundException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
Note: If writeClass(java.io.OutputStream)
is not called before
this method, any instrumentation performed on the last loaded class
will be lost.
className
- Name of the class to be loaded.
BadFileFormatException
- If the class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to load the
class.
java.io.FileNotFoundException
public void loadClass(java.lang.String className, java.io.InputStream source) throws BadFileFormatException, java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
Note: If writeClass(java.io.OutputStream)
is not called before
this method, any instrumentation performed on the last loaded class
will be lost.
className
- Name of the class to be loaded.source
- Stream from which the class should be read.
BadFileFormatException
- If the specified class is an interface.
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If BCEL cannot parse the class.
java.lang.Exception
- If any other error is raised attempting to
load the class.public void reloadClass() throws java.io.IOException, java.lang.ClassFormatError, java.lang.Exception
java.io.IOException
- If there is an error reading the class file.
java.lang.ClassFormatError
- If the class file cannot be parsed.
java.lang.Exception
- If any other error is raised attempting to parse the
class.public void reloadMethod(java.lang.String methodName, org.apache.bcel.generic.Type returnType, org.apache.bcel.generic.Type[] argumentTypes) throws MethodNotFoundException
methodName
- Name of the method to be reloaded.returnType
- Return type of the method.argumentTypes
- The types of the arguments to the method. Together
with the return type, these constitute the signature which will be used
to identify a match.
MethodNotFoundException
- If no method matching the specified name
and signature can be found.public int getPort()
public void setPort(int port, boolean auto)
Warning: This method should be used with caution. Only the
first occurrence of an invocation of SocketProbe.start
during execution will cause the port to be set. The method where the
call to SocketProbe.start
has been inserted must be
re-instrumented for the change to take effect. The
hasMain()
and hasStaticInit()
methods can be used to determine which method in the class represents
the first executable code that can be run by the class, if that is the
preferred location for the call to SocketProbe.start
. A
call to instrumentAll()
will also cause the change
to take effect.
port
- Port which is to be used for instrumentation. The valid
range is 1024 to 65535.auto
- If true
, set to the default port.public java.lang.String getClassName()
public java.lang.String getQualifiedName()
public int getInstMode()
public void setInstMode(int instMode) throws java.lang.IllegalStateException, java.lang.IllegalArgumentException
instMode
- Integer flag indicating the form of instrumentation to
be inserted. Acceptable values are the following:
java.lang.IllegalStateException
- If methods in the class have already
been instrumented using a different form of instrumentation. Call
reloadClass()
to begin instrumenting the current
class with a different form of instrumentation.
java.lang.IllegalArgumentException
- If the instrumentation mode is
invalid.public int getTypeFlags()
public abstract void setTypeFlags(int typeFlags)
typeFlags
- Bit mask representing the types of objects to be
instrumented.
java.lang.IllegalArgumentException
- If the bit mask doesn't have a set
bit which corresponds to a valid object type.protected abstract SConstants.TraceObjectType getObjectType()
protected abstract java.lang.String getProbeClassName()
public int getMethodCount()
public java.lang.String getMethodName(int methodIndex)
methodIndex
- Index of the method whose name is to be retrieved.
public java.lang.String getMethodSignature(int methodIndex)
methodIndex
- Index of the method whose name is to be retrieved.
public java.lang.String getLastInstrumented()
This may be useful to determine when a method is actually
instrumented. Methods declared as native
,
abstract
, or which have no method body will not cause
the value returned by this method to be updated.
null
if no method has been instrumented yet.public boolean hasMain()
true
if the class has a main
method,
false
otherwise.public boolean hasStaticInit()
true
if the class has a
<clinit>
method, false
otherwise.public void instrumentAll()
This method will automatically determine the correct method into
which to insert the call to SocketProbe.start
.
public void instrument(java.lang.String methodName, org.apache.bcel.generic.Type returnType, org.apache.bcel.generic.Type[] argumentTypes, boolean insertStarter) throws MethodNotFoundException
methodName
- Name of the method to be reloaded.returnType
- Return type of the method.argumentTypes
- The types of the arguments to the method. Together
with the return type, these constitute the signature which will be used
to identify a match.insertStarter
- Flag specifying whether call to
SocketProbe.start
should be unconditionally inserted at
the beginning of this method. The SocketProbe.start
method
is guarded against multiple invocations, such that only the first
occurrence during execution has any effect. Nonetheless, setting this
flag should be done with discretion and is generally discouraged. Note
also that the instrumentAll()
method will cause the
call to be automatically inserted in the appropriate location.
MethodNotFoundException
- If no method matching the specified
name and signature can be found.protected abstract org.apache.bcel.classfile.Method instrument(org.apache.bcel.classfile.Method m, int methodIndex, boolean insertStarter)
Performs the actual instrumentation and update of the method in the class.
m
- Method to be instrumented.methodIndex
- Index to the method in the class method array.insertStarter
- If true
, force the instrumentor to
insert a call to SocketProbe.start
at the beginning of
this method, otherwise it will be determined automatically whether it
should be inserted.
native
,
abstract
, or has no body, it is returned unchanged.public void insertStarter(java.lang.String methodName, org.apache.bcel.generic.Type returnType, org.apache.bcel.generic.Type[] argumentTypes) throws MethodNotFoundException
SocketProbe.start
unconditionally at
the beginning of the specified method.
The SocketProbe.start
method is guarded against
multiple invocations, such that only the first occurrence during
execution has any effect. Nonetheless, this method should be used with
discretion and such use is generally discouraged. Note also that the
instrumentAll()
method will cause the call to be
automatically inserted in the appropriate location.
methodName
- Name of the method into which to insert call.returnType
- Return type of the method.argumentTypes
- The types of the arguments to the method. Together
with the return type, these constitute the signature which will be used
to identify a match.
MethodNotFoundException
- If no method matching the specified
name and signature can be found.public void insertFinisher(java.lang.String methodName, org.apache.bcel.generic.Type returnType, org.apache.bcel.generic.Type[] argumentTypes) throws MethodNotFoundException
SocketProbe.finish
unconditionally at
the exit points of the specified method.
Warning: Use this method with extreme caution. The
SocketProbe.finish
method causes the SocketProbe to
transmit all remaining trace data and close its socket(s). Thus it
should be called only once, and after all possible instrumentation
has been executed, or errors and data loss will occur. Note also
that the instrumentAll()
method will cause the
call to be automatically inserted in the appropriate location.
methodName
- Name of the method into which to insert call.returnType
- Return type of the method.argumentTypes
- The types of the arguments to the method. Together
with the return type, these constitute the signature which will be used
to identify a match.
MethodNotFoundException
- If no method matching the specified
name and signature can be found.public org.apache.bcel.classfile.JavaClass generateClass()
public void writeClass(java.io.OutputStream dest) throws java.io.IOException
The class data written constitutes a valid Java class file. In other words, if the output stream is a file, the resulting file will be a valid class file containing any instrumentation that was applied.
dest
- Output stream to which class is to be written.
java.io.IOException
- If there is an error writing to the stream.protected void insertProbeStartCall(org.apache.bcel.generic.InstructionList il)
SocketProbe.start(int,int,boolean,boolean,int)
at beginning of method.
The call to
SocketProbe.start(int,int,boolean,boolean,int)
will be the very first instruction in the method. It should be inserted
into the static initializer (<clinit>), or the main
method if no static initializer is present. Otherwise, instrumentation
calls to SocketProbe may fail.
il
- The instruction list of the method into which the call is
to be inserted.protected void insertProbeFinishCall(org.apache.bcel.generic.InstructionList il)
SocketProbe.finish()
immediately prior to any return
instruction in the method.
il
- The instruction list of the method into which the call is to
be inserted.protected void addDefaultHandler(org.apache.bcel.generic.MethodGen mg, org.apache.bcel.generic.InstructionList il)
main
method, if necessary, to prevent
unhandled exceptions from being thrown.
This method wraps the entire main
method with a generic
handler for any java.lang.Throwable
and eliminates the
throws
declarations. The handler will emulate the behavior
of the ThreadGroup
class's uncaughtException
method. This is effectively a workaround for a stream-redirection
related bug in the SDK or JVM implementation that results in
non-deterministic display of subject outputs through Filter when
exceptions are thrown from the main
method.
mg
- The BCEL mutable representation of the method, required to
manipulate the throws clauses and handlers associated with the method.il
- The instruction list of the method, used to insert the
actual handler instructions.protected void cacheHandlerStarts(org.apache.bcel.generic.CodeExceptionGen[] excHandlers)
During the sequence instrumentation process, this cache is consulted to determine whether a block is the lead block of an exception handler. If it is, a call to record the possible change in method (exceptional return) to the trace is inserted.
excHandlers
- Table of exception handlers attached to the method.protected void loadBlockRefs(Block[] blocks, org.apache.bcel.generic.InstructionList il)
Warning: This method must be called before any changes are made to the instruction list! By ensuring this condition, this method can use what is presumed to be a faster lookup method to locate handles in the list.
blocks
- List of blocks for which the reference fields should
be assigned the instruction handles corresponding to the start
and end offsets of the block.il
- BCEL instruction list from which instruction handles
are to be loaded.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |