APIdia Launch Partner
Top Description Inners Fields Constructors Methods
jdk.jfr.consumer

public sealed Class RecordedObject

extends Object
permits RecordedEvent, RecordedClassLoader, RecordedClass, RecordedMethod, RecordedStackTrace, RecordedFrame, RecordedThread, RecordedThreadGroup
Class Inheritance
Known Direct Subclasses
jdk.jfr.consumer.RecordedStackTrace, jdk.jfr.consumer.RecordedThread, jdk.jfr.consumer.RecordedThreadGroup, jdk.jfr.consumer.RecordedClass, jdk.jfr.consumer.RecordedClassLoader, jdk.jfr.consumer.RecordedEvent, jdk.jfr.consumer.RecordedFrame, jdk.jfr.consumer.RecordedMethod
Imports
java.io.IOException, .PrintWriter, .StringWriter, java.nio.file.Path, java.time.Duration, .Instant, .OffsetDateTime, java.time.temporal.ChronoUnit, java.util.Comparator, .List, .Objects, java.util.function.Predicate, jdk.jfr.Configuration, .EventType, .Timespan, .Timestamp, .ValueDescriptor, jdk.jfr.internal.PrivateAccess, .Type, jdk.jfr.internal.consumer.JdkJfrConsumer, .ObjectContext, .ObjectFactory, jdk.jfr.internal.consumer.filter.ChunkWriter.RemovedEvents, jdk.jfr.internal.tool.PrettyWriter

A complex data type that consists of one or more fields.

This class provides methods to select and query nested objects by passing a dot "." delimited String object (for instance, "aaa.bbb"). A method evaluates a nested object from left to right, and if a part is null, it throws NullPointerException.

Since
9

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
pack-priv static final Integer
pack-priv static final Integer
pack-priv static final Long
pack-priv final ObjectContext
pack-priv final Object[]

Constructor Summary

AccessConstructor and Description
pack-priv
RecordedObject(ObjectContext objectContext, Object[] objects)

Method Summary

Modifier and TypeMethod and Description
public final boolean

Returns:

the value of the field, true or false
getBoolean
(String
name of the field to get, not null
name
)

Returns the value of a field of type boolean.

public final byte

Returns:

the value of the field
getByte
(String
of the field to get, not null
name
)

Returns the value of a field of type byte.

public final char

Returns:

the value of the field as a char
getChar
(String
of the field to get, not null
name
)

Returns the value of a field of type char.

public final RecordedClass

Returns:

the value of the field as a RecordedClass, can be null
getClass
(String
of the field to get, not null
name
)

Returns the value of a field of type Class.

public final double

Returns:

the value of the field converted to type double
getDouble
(String
of the field to get, not null
name
)

Returns the value of a field of type double or of another primitive type that is convertible to type double by a widening conversion.

public final Duration

Returns:

a time span represented as a Duration, not null
getDuration
(String
of the field to get, not null
name
)

Returns the value of a timespan field.

private Duration
getDuration(long timespan, String name)

public List<ValueDescriptor>

Returns:

the fields, not null
getFields
()

Returns an immutable list of the fields for this object.

public final float

Returns:

the value of the field converted to type float
getFloat
(String
of the field to get, not null
name
)

Returns the value of a field of type float or of another primitive type convertible to type float by a widening conversion.

public final Instant

Returns:

a timstamp represented as an Instant, not null
getInstant
(String
of the field to get, not null
name
)

Returns the value of a timestamp field.

private Instant
getInstant(long timestamp, String name)

public final int

Returns:

the value of the field converted to type int
getInt
(String
of the field to get, not null
name
)

Returns the value of a field of type int or of another primitive type that is convertible to type int by a widening conversion.

public final long

Returns:

the value of the field converted to type long
getLong
(String
of the field to get, not null
name
)

Returns the value of a field of type long or of another primitive type that is convertible to type long by a widening conversion.

private OffsetDateTime
public final short

Returns:

the value of the field converted to type short
getShort
(String
of the field to get, not null
name
)

Returns the value of a field of type short or of another primitive type convertible to type short by a widening conversion.

public final String

Returns:

the value of the field as a String, can be null
getString
(String
of the field to get, not null
name
)

Returns the value of a field of type String.

public final RecordedThread

Returns:

the value of the field as a RecordedThread object, can be null
getThread
(String
of the field to get, not null
name
)

Returns the value of a field of type Thread.

pack-priv final <T> T
getTyped(String name, Class<T> clazz, T defaultValue)

private <T> T
getTypedValue(String name, String typeName)

public final <
the return type
T
>
T

Returns:

the value, can be null
getValue
(String
of the field to get, not null
name
)

Returns the value of the field with the given name.

private Object
getValue(String name, boolean allowUnsigned)

private ValueDescriptor
getValueDescriptor(List<ValueDescriptor> descriptors, String name, String leafType)

public boolean

Returns:

true if the field exists, false otherwise
hasField
(String
name of the field to get, not null
name
)

Returns true if a field with the given name exists, false otherwise.

private boolean
private static IllegalArgumentException
pack-priv Object
objectAt(int index)

private Object[]
structifyArray(ValueDescriptor v, Object[] array, int dimension)

public final String

Returns:

textual description of this object
toString
()

Overrides java.lang.Object.toString.

Returns a textual representation of this object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

INTEGER_MINUS_ONEback to summary
pack-priv static final Integer INTEGER_MINUS_ONE
INTEGER_ZEROback to summary
pack-priv static final Integer INTEGER_ZERO
LONG_MINUS_ONEback to summary
pack-priv static final Long LONG_MINUS_ONE
objectContextback to summary
pack-priv final ObjectContext objectContext
objectsback to summary
pack-priv final Object[] objects

Constructor Detail

RecordedObjectback to summary
pack-priv RecordedObject(ObjectContext objectContext, Object[] objects)

Method Detail

getBooleanback to summary
public final boolean getBoolean(String name)

Returns the value of a field of type boolean.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

name of the field to get, not null

Returns:boolean

the value of the field, true or false

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field is not of type boolean
See Also
hasField(String), getValue(String)
getByteback to summary
public final byte getByte(String name)

Returns the value of a field of type byte.

It's possible to index into a nested object using "." (for example, "foo.bar").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:byte

the value of the field

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field is not of type byte
See Also
hasField(String), getValue(String)
getCharback to summary
public final char getChar(String name)

Returns the value of a field of type char.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:char

the value of the field as a char

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field is not of type char
See Also
hasField(String), getValue(String)
getClassback to summary
public final RecordedClass getClass(String name)

Returns the value of a field of type Class.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:RecordedClass

the value of the field as a RecordedClass, can be null

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field isn't of type Class
See Also
hasField(String), getValue(String)
getDoubleback to summary
public final double getDouble(String name)

Returns the value of a field of type double or of another primitive type that is convertible to type double by a widening conversion.

This method can be used on fields of the following types: double, float, long, int, short, char, and byte.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:double

the value of the field converted to type double

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to the type double by a widening conversion
See Also
hasField(String), getValue(String)
getDurationback to summary
public final Duration getDuration(String name)

Returns the value of a timespan field.

This method can be used on fields annotated with @Timespan, and of the following types: long, int, short, char, and byte.

If the committed event value was Long.MAX_VALUE, regardless of the unit set by @Timespan, this method returns ChronoUnit#FOREVER.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:Duration

a time span represented as a Duration, not null

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to a Duration object
See Also
hasField(String), getValue(String)
getDurationback to summary
private Duration getDuration(long timespan, String name)
getFieldsback to summary
public List<ValueDescriptor> getFields()

Returns an immutable list of the fields for this object.

Returns:List<ValueDescriptor>

the fields, not null

getFloatback to summary
public final float getFloat(String name)

Returns the value of a field of type float or of another primitive type convertible to type float by a widening conversion.

This method can be used on fields of the following types: float, long, int, short, char, and byte.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:float

the value of the field converted to type float

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to the type float by a widening conversion
See Also
hasField(String), getValue(String)
getInstantback to summary
public final Instant getInstant(String name)

Returns the value of a timestamp field.

This method can be used on fields annotated with @Timestamp, and of the following types: long, int, short, char and byte.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:Instant

a timstamp represented as an Instant, not null

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to an Instant object
See Also
hasField(String), getValue(String)
getInstantback to summary
private Instant getInstant(long timestamp, String name)
getIntback to summary
public final int getInt(String name)

Returns the value of a field of type int or of another primitive type that is convertible to type int by a widening conversion.

This method can be used on fields of the following types: int, short, char, and byte.

If the field has the @Unsigned annotation and is of a narrower type than int, then the value will be returned as an unsigned.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:int

the value of the field converted to type int

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to the type int by a widening conversion
See Also
hasField(String), getValue(String)
getLongback to summary
public final long getLong(String name)

Returns the value of a field of type long or of another primitive type that is convertible to type long by a widening conversion.

This method can be used on fields of the following types: long, int, short, char, and byte.

If the field has the @Unsigned annotation and is of a narrower type than long, then the value will be returned as an unsigned.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:long

the value of the field converted to type long

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to the type long via a widening conversion
See Also
hasField(String), getValue(String)
getOffsetDateTimeback to summary
private OffsetDateTime getOffsetDateTime(String name)
getShortback to summary
public final short getShort(String name)

Returns the value of a field of type short or of another primitive type convertible to type short by a widening conversion.

This method can be used on the following types: short and byte.

If the field has the @Unsigned annotation and is of a narrower type than short, then the value is returned as an unsigned.

It's possible to index into a nested object using "." (for example, "aaa.bbb").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:short

the value of the field converted to type short

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field value can't be converted to the type short by a widening conversion
See Also
hasField(String), getValue(String)
getStringback to summary
public final String getString(String name)

Returns the value of a field of type String.

It's possible to index into a nested object using "." (for example, "foo.bar").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:String

the value of the field as a String, can be null

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field isn't of type String
See Also
hasField(String), getValue(String)
getThreadback to summary
public final RecordedThread getThread(String name)

Returns the value of a field of type Thread.

It's possible to index into a nested object using "." (for example, "foo.bar").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Parameters
name:String

of the field to get, not null

Returns:RecordedThread

the value of the field as a RecordedThread object, can be null

Exceptions
IllegalArgumentException:
if the field doesn't exist, or the field isn't of type Thread
See Also
hasField(String), getValue(String)
getTypedback to summary
pack-priv final <T> T getTyped(String name, Class<T> clazz, T defaultValue)
getTypedValueback to summary
private <T> T getTypedValue(String name, String typeName)
getValueback to summary
public final <T> T getValue(String name)

Returns the value of the field with the given name.

The return type may be a primitive type or a subclass of RecordedObject.

It's possible to index into a nested object by using "." (for instance "thread.group.parent.name").

A field might change or be removed in a future JDK release. A best practice for callers of this method is to validate the field before attempting access.

Example

if (event.hasField("intValue")) { int intValue = event.getValue("intValue"); System.out.println("Int value: " + intValue); } if (event.hasField("objectClass")) { RecordedClass clazz = event.getValue("objectClass"); System.out.println("Class name: " + clazz.getName()); } if (event.hasField("sampledThread")) { RecordedThread sampledThread = event.getValue("sampledThread"); System.out.println("Sampled thread: " + sampledThread.getJavaName()); }
if (event.hasField("intValue")) {
    int intValue = event.getValue("intValue");
    System.out.println("Int value: " + intValue);
}

if (event.hasField("objectClass")) {
    RecordedClass clazz = event.getValue("objectClass");
    System.out.println("Class name: " + clazz.getName());
}

if (event.hasField("sampledThread")) {
    RecordedThread sampledThread = event.getValue("sampledThread");
    System.out.println("Sampled thread: " + sampledThread.getJavaName());
}
Parameters
<T>
the return type
name:String

of the field to get, not null

Returns:T

the value, can be null

Exceptions
IllegalArgumentException:
if no field called name exists
See Also
hasField(String)
getValueback to summary
private Object getValue(String name, boolean allowUnsigned)
getValueDescriptorback to summary
private ValueDescriptor getValueDescriptor(List<ValueDescriptor> descriptors, String name, String leafType)
hasFieldback to summary
public boolean hasField(String name)

Returns true if a field with the given name exists, false otherwise.

It's possible to index into a nested field by using "." (for instance "thread.group.parent.name").

Parameters
name:String

name of the field to get, not null

Returns:boolean

true if the field exists, false otherwise

See Also
getFields()
isStackFrameTypeback to summary
private boolean isStackFrameType(String typeName)
newIllegalArgumentExceptionback to summary
private static IllegalArgumentException newIllegalArgumentException(String name, String typeName)
objectAtback to summary
pack-priv Object objectAt(int index)
structifyArrayback to summary
private Object[] structifyArray(ValueDescriptor v, Object[] array, int dimension)
toStringback to summary
public final String toString()

Overrides java.lang.Object.toString.

Returns a textual representation of this object.

Returns:String

textual description of this object

Annotations
@Override
jdk.jfr.consumer back to summary

private final Record RecordedObject.UnsignedValue

extends Record
Class Inheritance
Record Components
value:Object 

Field Summary

Modifier and TypeField and Description
private final Object
value

Record Component accessed by value().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

public Object
value()

Record Component getter of value.

Field Detail

valueback to summary
private final Object value

Record Component accessed by value().

Constructor Detail

UnsignedValueback to summary
private UnsignedValue(Object value)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

valueback to summary
public Object value()

Record Component getter of value.