--> Probe static fields

Probe static fields

A probe's static field inserts a new static field into every Java class containing at least one method instrumented by the probe. This static field is accessible to probe fragments, and can be used to store information inside probed classes.

The term static field refers to a field of the class that is declared static. This is sometimes called a static variable, a class field, or a class variable (versus an instance variable).

The static field specification is optional.

A static field has the following property:

Property Description
type Required. The type property specifies the Java type string for the new field. The string must be a fully-qualified Java class name; for example: java/lang/StringBuffer. The type string must represent an ordinary class type, not a primitive type or an array type. The named class must have a default constructor (, a constructor that takes no arguments) accessible to the probed class.
When you use a static field, the new static field is initialized in the probed class by a call to the default constructor for its type. For example, adding a static field of type StringBuffer is like adding the following code to the class outside of all methods:
static private StringBuffer fieldName = new StringBuffer();

The initialization call is made at the start of the class initializer for the probed class. If the class does not have a class initializer, one will be created. If the probe has a staticInitializer fragment, the staticInitializer fragment code runs after the static field has been constructed.

Probe fragments can use the staticField data item to access the object referenced by the static field. Fragments can change the state of the object that the static field refers to, but they cannot make the static field refer to a different object.

A probe can have only one static field specified. To use the static field specification to store more than one item in the probed class, use a composite object type such as ArrayList, HashMap, or HashSet, or define and use a new class with the data structure you need.

Example:

To enter a static field, right-click Probe in the editor's tree pane, then click New > Static Field. Enter the Java type in the editing pane.

Related reference
The staticInitializer probe fragment type
Related information
A staticField and staticInitializer probe example