|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ClassInstrumentation
Contains information about a class that has been instrumented. This allows
CodePosition objects to be created for the class.
CodePositions are often specified relative to methods. For example, a CodePosition can be created at the beginning of a particular method within the instrumented class. When referring to methods, two approaches are offered: by name, and by a Method object. Names are simpler, but can be ambiguous when overloading is used. Given the following code:
public void printMessage(); public void printMessage(PrintStream output);a simple reference to the method "printMessage" is ambiguous. In order to specify which version of
printMessage is being referred to,
specify a CodePosition using a Method object. See atMethodStart(String) and atMethodStart(Method).
If an ambiguous method is referred to by name, then an
IllegalArgumentException will be thrown. In addition, if a reference is made
to a non-existent or invalid method, an IllegalArgumentException will be
thrown.
Note that CodePositions can only be created for methods directly defined in
the corresponding Class. Given a class Foo, the ClassInstrumentation
corresponding to Foo can only be used to create breakpoints in
methods defined directly in Foo. (I.e. for methods that can be
obtained by invoking Foo.class.getDeclaredMethod().)
CodePositions cannot be created in constructors.
| Method Summary | |
|---|---|
CodePosition |
afterCall(Method caller,
Method called)
Returns a CodePosition just after a call made within a method. |
CodePosition |
afterCall(String caller,
String called)
Returns a CodePosition just after a call made within a method. |
CodePosition |
afterSync(Method method,
Object syncTarget)
Returns a CodePosition representing the end of a synchronized block, after the lock has been released |
CodePosition |
afterSync(String methodName,
Object syncTarget)
Returns a CodePosition representing the end of a synchronized block, after the lock has been released |
CodePosition |
atMethodEnd(Method method)
Returns a CodePosition representing the end of a method, after all of the code in the method has executed. |
CodePosition |
atMethodEnd(String methodName)
Returns a CodePosition representing the end of a method, after all of the code in the method has executed. |
CodePosition |
atMethodStart(Method method)
Returns a CodePosition representing the start of a method, before any of the code in the method executes. |
CodePosition |
atMethodStart(String methodName)
Returns a CodePosition representing the start of a method, before any of the code in the method executes. |
CodePosition |
beforeCall(Method caller,
Method called)
Returns a CodePosition just before a call made within a method. |
CodePosition |
beforeCall(String caller,
String called)
Returns a CodePosition just before a call to a target method from within the main method. |
CodePosition |
beforeSync(Method method,
Object syncTarget)
Returns a CodePosition representing the start of a synchronized block, before the lock has beebn taken. |
CodePosition |
beforeSync(String methodName,
Object syncTarget)
Returns a CodePosition representing the start of a synchronized block, before the lock has beebn taken. |
MethodInstrumentation |
getMethod(Method method)
Returns the instrumented method for the given method. |
MethodInstrumentation |
getMethod(String methodName)
Returns the instrumented method for the given method name. |
Collection<MethodInstrumentation> |
getMethods()
Returns the instrumented methods in this class. |
| Method Detail |
|---|
CodePosition atMethodStart(String methodName)
CodePosition atMethodStart(Method method)
CodePosition atMethodEnd(String methodName)
Breakpoint created at this position will still be hit.
CodePosition atMethodEnd(Method method)
Breakpoint created at this position will still be hit.
CodePosition beforeCall(String caller,
String called)
Given the following code in the class:
public void printSomething() {
System.out.printf("Hello\n");
}
Then we can get the CodePoint representing a position just before the call
to "printf" made within the method "printSomething" by:
CodePosition cp = beforeCall("printSomething", "printf",...);
caller - the name of the method in which the position should be created.called - the name of the target method.
CodePosition beforeCall(Method caller,
Method called)
beforeCall(Method, Method).
caller - the method in which the position should be created.called - the target method.
CodePosition afterCall(String caller,
String called)
Given the following code in the class:
public void printSomething() {
System.out.printf("Hello\n");
}
Then we can get the CodePoint representing a position just after the call
to "printf" made within the method "printSomething" by:
CodePosition cp = afterCall("printSomething", "printf",...);
caller - the name of the method in which the position should be createdcalled - the name of the target method
CodePosition afterCall(Method caller,
Method called)
afterCall(Method, Method).
caller - the method in which the position should be created.called - the target method.
CodePosition beforeSync(String methodName,
Object syncTarget)
methodName - the name of the method containing the synchronized block.syncTarget - the object being synchronized.
CodePosition beforeSync(Method method,
Object syncTarget)
method - the method containing the synchronized block.syncTarget - the object being synchronized.
CodePosition afterSync(String methodName,
Object syncTarget)
methodName - the name of the method containing the synchronized block.syncTarget - the object being synchronized.
CodePosition afterSync(Method method,
Object syncTarget)
method - the method containing the synchronized block.syncTarget - the object being synchronized.
Collection<MethodInstrumentation> getMethods()
MethodInstrumentation getMethod(String methodName)
MethodInstrumentation getMethod(Method method)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||