Java Profiler 9.0 Help
Probes: extendable profiling and monitoring
Monitoring method invocation events
Probe class annotation @MethodPattern
Probe class must be annotated with @MethodPattern annotation
in order to specify which methods the callbacks will be applied to.
One or more method patterns can be specified in the following format ('*' wildcard is allowed):
class_name : method_name ( parameters )
|
Part
|
Description
|
Examples
|
class_name |
Full qualified class name, dot-separated. Inner classes are separated with dots too. |
Particular class:
Class with name ending with 'Helper':
Any class in a package:
Any class: |
method_name |
Method name. To specify a constructor, use its classes short name. |
Method with particular name:
Any getter:
Any method, including constructors: |
parameters |
Comma-separated list of parameter types. Space characters between type names and commas are allowed (but not required).
Class names should be full qualified, dot-separated,
except for
Primitive classes are specified in format used in Java source code:
Arrays are specified as Use empty string to specify a method with no parameters.
|
No parameters: empty
Any number of parameters, including zero:
3 parameters of particular types:
First parameter is an array of class com.Foo:
|
The annotation is declared as...
package com.yourkit.probes;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
public @interface MethodPattern {
String[] value();
}
...and allows to specify one or more patterns for a probe. For example:
import com.yourkit.probes.*;
// Instrument calls of method 'findPerson' in class 'com.foo.Person', which has 2 parameters of particular types
@MethodPattern("com.foo.Person:findPerson(String, int)")
public class MyProbe1 {
//...
}
// Instrument all methods in classes 'com.Foo' and 'com.Bar'
@MethodPattern(
{
// should match at least one of them
"com.Foo:*(*)",
"com.Bar:*(*)"
}
)
public class MyProbe2 {
//...
}
// Instrument methods toString() in all classes in package com.foo
@MethodPattern("com.foo.*:toString()")
public class MyProbe3 {
//...
}
// Instrument all methods in classes whose names end with 'Helper' and have int[][] as a first parameter
@MethodPattern("*Helper:(int[][],*)")
public class MyProbe4 {
//...
}