The Shared Fields Analysis is a dynamic analysis that records how often an object’s fields are accessed by different threads. For this purpose, the analysis distinguishes between the object’s allocating thread and all other threads; if another thread besides its allocating thread accesses a field, then that field is shared.
The format of the profile is record‐oriented; each object on the heap corresponds to one multi‐line record in the produced profile.
Below is an excerpt from a real‐world profile:
java/nio/ByteBuffer␜wrap␜([BII)Ljava/nio/ByteBuffer;␜2 java.nio.HeapByteBuffer java.nio.Buffer␜address␜J 0 0 0 0 java.nio.Buffer␜capacity␜I 1 0 1 0 java.nio.Buffer␜limit␜I 6 0 1 0 java.nio.Buffer␜position␜I 5 0 3 0 java.nio.Buffer␜mark␜I 3 0 1 0 java.nio.ByteBuffer␜nativeByteOrder␜Z 0 0 1 0 java.nio.ByteBuffer␜bigEndian␜Z 0 0 1 0 java.nio.ByteBuffer␜isReadOnly␜Z 5 0 0 0 java.nio.ByteBuffer␜offset␜I 3 0 1 0 java.nio.ByteBuffer␜hb␜[B 6 0 1 0 java/util/Arrays␜copyOf␜([CI)[C␜2 [C [C␜$arraylength␜I 54 0 0 0 [C␜$components␜? 0 0 53 0
The first line of each record identifies an object’s allocation site and type in the first and second column, respectively. The allocation site is described by a quadruple of class name, method name, method descriptor, and the index of the instruction (new, newarray, anewarray, multianewarray) that performed the allocation. The four components are separated by the “File Separator” control character ('\034'). And instruction index of −1 indicates that the object was allocated using reflection, with the other three components identifying the method performing the allocation (Constructor/Array.newInstance(…)). If an allocation site could not be determined by the Shared Fields Analysis, this is indicated by a question mark.
The remaining lines of a record report the number of read and write accesses to the object’s fields. The first column of each such line identifies the field, described by a triple of class name, field name, and type descriptor, again with components separated by the “File Separator” control character ('\034'). Arrays are modelled as objects having two synthetic $arraylength and $components fields. The remaining four columns then report the number of reads performed by the allocating thread, the number of reads performed by other threads, the number of writes performed by the allocating thread, and the number of writes performed by other threads, respectively.