Detect Method (detectMethod)
<detectMethod> Element
The detectMethod rule is used for detecting methods in Java class files.
| Attribute Name | Type | Required | Description |
|---|---|---|---|
| name | String | Yes |
The method name. If providing multiple, use a comma separated list. |
| owners | String | Yes |
The fully qualified class name of the class where the method is defined. If providing multiple, use a comma separated list. |
| returnType | String | No |
The fully qualified class name of the return type. |
| arguments | String | No |
The fully qualified class names or primitives of the method arguments. If specifying multiple, use a comma separated list. Specify an empty string to flag the method with no parameters. If not specified, flag all method signatures. |
| excludePackageNames | String | No |
The fully qualified package names. If providing multiple use a comma separated list. This can be used to exclude flagging methods on classes in certain packages. Add .* to the package to match all sub-packages. Add just * to the package name to match that package as well as all sub-packages. |
| flagCatchExceptions | String | No |
The fully qualified class names of the exceptions. If specifying multiple, use a comma separated list. Flag calls to the method if it is inside a try and catch block for any of the specified exceptions. |
| flagUnhandledExceptions | String | No |
Fully qualified class names of the exceptions. If specifying multiple, use a comma separated list. Flag calls to the method if none of the specified exceptions are caught or thrown by the invoking method. |
| flagOnce | Boolean | No |
Indicates whether to flag once per archive. Defaults to false. |
| flagOncePerFile | Boolean | No |
Indicates whether to flag once per file. Defaults to false. |
| hideResult | Boolean | No |
Indicates whether results flagged by this rule should be hidden in the report. This attribute only hides results when used with rules under the <and> or <or> tags. Defaults to false. |
For example, to detect the load method from the java.util.Properties class with any method signature, specify:
<detectMethod name="load" owners="java.util.Properties"/>