The Fragment probe object

The Fragment probe object is a specification of a probe's logic. It contains the Java source code that will be executed.

At least one Fragment object is required. It contains the Code object, and all data items that are referenced by the source code in the Code object. A probe can contain more than one Fragment object, but no two Fragment objects can have the same type.

The Fragment object includes the following property:

Property Description
type Required. For method probes, it must be entry, exit, catch, staticInitializer, or executableUnit. For callsite probes, it must be beforeCall or afterCall. You cannot mix method fragments and callsite fragments in a single probe.

The following table lists and describes the fragment types, and indicates the type of probe each can be used in:

Fragment type Probe type Description
entry Method entry fragments execute upon method entry. entry fragments will not execute for methods that were inserted into the class by Probekit.
exit Method exit fragments execute upon method exit; either a normal exit, when the method throws an exception, or when a thrown exception propagates out of the method. exit fragments will not execute for methods that were inserted into the class by Probekit.
catch Method catch fragments execute at the beginning of a catch clause in the method, or at the beginning of a finally clause that executes as the result of an exception.
staticInitializer Method staticInitializer fragments execute 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.
executableUnit Method executableUnit fragments execute 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.
beforeCall callsite beforeCall fragments execute in the calling method immediately before the target method is called. Not valid for method probes.
afterCall callsite afterCall fragments execute 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.

Notes:

Example

<fragment type="entry"> 
   <data . . . />
   <code>
      . . . 
   </code>
</fragment>

Contained by
The Probe object

Contains
The Data probe object
The Code probe object

 

Parent topic

Probekit Reference

 

Related concepts

Method probes versus callsite probes