The Fragment probe object

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

The 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.

A probe fragment can be one of the following types:
  • entry fragments execute upon method entry
  • 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
  • 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
  • beforeCall fragments (for callsite probes) execute in the calling method immediately before the target method is called
  • afterCall fragments (for callsite probes) execute in the calling method immediately after the target method exits; either a normal exit, or when the target method throws an exception
Note: When a probe is applied to a synchronized method, the probe’s fragments are executed as follows:
  • the entry fragment executes before the method synchronization logic obtains a lock
  • the exit fragment executes after the lock has been released
  • even though the probed method is declared synchronized, the code in the entry and exit fragments are not protected from simultaneous execution on multiple threads

The Fragment object includes the following property:

typeRequired. For method probes, it must be entry, catch, or exit. For callsite probes, it must be beforeCall or afterCall. You cannot mix method fragments and callsite fragments in a single probe.
Example
<fragment type="entry"> 
   <data . . . />
   <code>
      . . . 
   </code>
</fragment>

Contained by
The Probe object

Related concepts
Method probes versus callsite probes

Related information
A basic sample probe

Copyright IBM Corporation and others 2000, 2004.