Filters methods based on class name, method name, method parameters and
return type. A filter is specified as follows:
[<returnType>] [<className>.]<methodName>
[(<paramTypes>)]
To match multiple methods, the individual filter elements (or their parts)
can be substituted with the "*" wild card character, which will expand to
zero or more non-whitespace characters. The individual filter elements have
the following meaning:
- <returnType>
- The type of the method's return value, specified either as a fully
qualified class name (for reference types) or a primitive type name. If not
specified, the filter will match all return types. For example:
- * or nothing
- matches all return types
- *.String
- matches methods returning a String class from any package, e.g.,
java.lang.String, or my.package.String.
- *String
- matches methods returning any class with a name ending with String from
any package, e.g., java.lang.String, my.package.String, or
my.package.BigString
- <className>
- Fully qualified name of the class containing the methods the filter is
supposed to match. If not specified, the filter will match all classes. The
package part of a class name can be omitted, in which case the filter will
match all packages. To match a class without a package name (i.e. in the
default package), specify the package name as "[default]". For example:
- * or nothing
- matches all classes
- TargetClass
- matches a class named TargetClass in any package
- [default].TargetClass
- matches a class named TargetClass only in the default package, i.e., it
does not match my.pkg.TargetClass
- TargetClass*
- matches any class with a name starting with TargetClass in any package,
e.g., TargetClassFoo in any package, or TargetClassBar in any package
- my.pkg.*Math
- matches any class with a name ending with Math in the my.pkg package and
all sub packages, e.g., my.pkg.Math, my.pkg.FastMath, my.pkg.new.FastMath, or
my.pkg.new.fast.Math
- <methodName>
- The name of the method the filter is supposed to match. This filter
element is mandatory, therefore to match any method name, the
<methodName> element must be replaced with a "*". To match class
initializers and class constructors, use their bytecode-internal names, i.e.,
"clinit" and "init", respectively. For example:
- *
- matches all methods
- *init
- matches class initializer (clinit), class constructor (init), and any
method with a name ending with "init"
- <paramTypes>
- A comma-separated list of method parameter types. Each parameter type is
specified either as a fully qualified class name or a primitive type name.
The filter parameter list can end with "..", which matches all remaining
method parameters. If not specified, the filter matches all methods
regardless of their parameter types. For example:
- (..)
- matches methods with any (including none) parameters, e.g., (), or (int)
- (int, int, ..)
- matches any method with at least two parameters, and the parameter list
starting with two integers, e.g., (int, int), (int, int, double), or (int,
int, Object, String)
- (java.lang.String, java.lang.String[])
- matches a method with exactly two parameters with matching types. The
types are matched verbatim, i.e., there is no matching based on subtyping.
To put it all together, consider the following complete examples:
- my.pkg.TargetClass.main(java.lang.String[])
- matches the "main" method in class my.pkg.TargetClass which takes as a
parameter an array of Strings. In this case, the return type is not
important, because the parameter signature is fully specified.
- int *
- matches all methods returning an integer value
- *(int, int, int)
- matches all methods accepting three integer values