Each fragment that you define requires a type specification. The type indicates when the fragment will run in the targeted methods. A probe can contain more than one fragment, but cannot contain more than one fragment of any given type.
Fragment type | Method or Callsite | Description |
---|---|---|
entry | Method | entry fragments run upon method entry. entry fragments will not run for methods that were inserted into the class by Probekit. |
exit | Method | exit fragments run upon method exit: a normal exit, when the method throws an exception, or when a thrown exception propagates out of the method. exit fragments will not run for methods that were inserted into the class by Probekit. |
catch | Method | catch fragments run at the beginning of a catch clause in the method, or at the beginning of a finally clause that runs as the result of an exception. |
staticInitializer | Method | staticInitializer fragments run inside the class initializer of every probed class. If the class does not already have a static initializer, one will be created. For more information, see The staticInitializer probe fragment type. |
executableUnit | Method | executableUnit fragments run before every executable unit of code in methods that match the probe's target and filter specification, and for which source code is available. If the method does not have source line information, it will appear to have a single executable unit, numbered zero. For more information, see The executableUnit probe fragment type. |
beforeCall | Callsite | beforeCall fragments run in the calling method immediately before the target method is called. Not valid for method probes. |
afterCall | Callsite | afterCall fragments run in the calling method immediately after the target method exits: either a normal exit, or when the target method throws an exception. Not valid for method probes. |
A probe can have multiple fragments that apply to the same location in a method: for example, an entry fragment and the first executableUnit location. Another example is a catch fragment and its associated executableUnit location, because catch clauses for exception handling always represent the start of a new executable unit. In these cases the executableUnit fragment's code will run after the entry or catch fragment's code. One consequence is that entry fragments, if present, will always run before other kinds of fragments.
You cannot mix method fragments and callsite fragments in a single probe, but you can have method probes and callsite probes in the same Probekit source file (probe file).
To specify a fragment type, select a Fragment entry in the tree pane of the Probes page, and make a selection from the Fragment Type list in the editing pane.