APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.jfr

public final Class ValueDescriptor

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.util.Collections, .List, .Objects, jdk.jfr.internal.AnnotationConstruct, .Type, jdk.jfr.internal.util.Utils

Describes the event fields and annotation elements.

The following example shows how the ValueDescriptor class can be used to list field information of all types.

void printTypes() { Map<String, List<ValueDescriptor>> typeMap = new LinkedHashMap<>(); for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) { findTypes(typeMap, eventType.getName(), eventType.getFields()); } for (String type : typeMap.keySet()) { System.out.println("Type: " + type); for (ValueDescriptor field : typeMap.get(type)) { System.out.println(" Field: " + field.getName()); String arrayBrackets = field.isArray() ? "[]" : ""; System.out.println(" Type: " + field.getTypeName() + arrayBrackets); if (field.getLabel() != null) { System.out.println(" Label: " + field.getLabel()); } if (field.getDescription() != null) { System.out.println(" Description: " + field.getDescription()); } if (field.getContentType() != null) { System.out.println(" Content Types: " + field.getContentType()); } } System.out.println(); } } void findTypes(Map<String, List<ValueDescriptor>> typeMap, String typeName, List<ValueDescriptor> fields) { if (!typeMap.containsKey(typeName)) { typeMap.put(typeName, fields); for (ValueDescriptor subField : fields) { findTypes(typeMap, subField.getTypeName(), subField.getFields()); } } }
void printTypes() {
    Map<String, List<ValueDescriptor>> typeMap = new LinkedHashMap<>();
    for (EventType eventType : FlightRecorder.getFlightRecorder().getEventTypes()) {
        findTypes(typeMap, eventType.getName(), eventType.getFields());
    }
    for (String type : typeMap.keySet()) {
        System.out.println("Type: " + type);
        for (ValueDescriptor field : typeMap.get(type)) {
            System.out.println(" Field: " + field.getName());
            String arrayBrackets = field.isArray() ? "[]" : "";
            System.out.println("  Type: " + field.getTypeName() + arrayBrackets);
            if (field.getLabel() != null) {
                System.out.println("  Label: " + field.getLabel());
            }
            if (field.getDescription() != null) {
                System.out.println("  Description: " + field.getDescription());
            }
            if (field.getContentType() != null) {
                System.out.println("  Content Types: " + field.getContentType());
            }
        }
        System.out.println();
    }
}

void findTypes(Map<String, List<ValueDescriptor>> typeMap, String typeName, List<ValueDescriptor> fields) {
    if (!typeMap.containsKey(typeName)) {
        typeMap.put(typeName, fields);
        for (ValueDescriptor subField : fields) {
            findTypes(typeMap, subField.getTypeName(), subField.getFields());
        }
    }
}
Since
9

Field Summary

Modifier and TypeField and Description
private final AnnotationConstruct
private final boolean
private String
private final boolean
private final String
private String
private final String
private final Type
private static final String

Constructor Summary

AccessConstructor and Description
pack-priv
ValueDescriptor(Type type, String name, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName)

public
ValueDescriptor(Class<?>
the type, not null
type
,
String
the name, not null
name
)

Constructs a value descriptor, useful for dynamically creating event types and annotations.

public
ValueDescriptor(Class<?>
the type, not null
type
,
String
the name, not null
name
,
List<AnnotationElement>
the annotations on the value descriptors, not null
annotations
)

Constructs a value descriptor, useful for dynamically creating event types and annotations.

pack-priv
ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray)

Method Summary

Modifier and TypeMethod and Description
public <
the type of the annotation to query for and return if present
A extends Annotation
>
A

Returns:

this element's annotation for the specified annotation type if directly present, else null
getAnnotation
(Class<A>
the Class object that corresponds to the annotation type, not null
annotationType
)

Returns the first annotation for the specified type if an annotation element with the same name is directly present for this value descriptor, null otherwise.

public List<AnnotationElement>

Returns:

a list of annotations, not null
getAnnotationElements
()

Returns an immutable list of annotation elements for this value descriptor.

public String

Returns:

the content type, or null if doesn't exist
getContentType
()

Returns a textual identifier that specifies how a value represented by this ValueDescriptor is interpreted or formatted.

public String

Returns:

the description, or null if doesn't exist
getDescription
()

Returns a sentence describing the value (for example, "Maximum throughput in the transaction system.

public List<ValueDescriptor>

Returns:

a list of value descriptors, not null
getFields
()

Returns an immutable list of value descriptors if the type is complex, else an empty list.

pack-priv String
public String

Returns:

a human-readable name, or null if doesn't exist
getLabel
()

Returns a human-readable name that describes the value (for example, "Maximum Throughput").

public String

Returns:

the name, not null
getName
()

Returns the name of the value (for example, "maxThroughput").

pack-priv Type
public long

Returns:

the type ID, not negative
getTypeId
()

Returns a unique ID for the type in the Java virtual Machine (JVM).

public String

Returns:

the type name, not null
getTypeName
()

Returns the fully qualified class name of the type that is associated with this value descriptor.

public boolean

Returns:

true if it is an array type, false otherwise
isArray
()

Returns if this value descriptor is an array type.

pack-priv boolean
pack-priv boolean
pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationConstructback to summary
private final AnnotationConstruct annotationConstruct
constantPoolback to summary
private final boolean constantPool
contentTypeback to summary
private String contentType
isArrayback to summary
private final boolean isArray
javaFieldNameback to summary
private final String javaFieldName
labelback to summary
private String label
nameback to summary
private final String name
typeback to summary
private final Type type
UNKNOWNback to summary
private static final String UNKNOWN

Constructor Detail

ValueDescriptorback to summary
pack-priv ValueDescriptor(Type type, String name, List<AnnotationElement> annotations, int dimension, boolean constantPool, String fieldName)
ValueDescriptorback to summary
public ValueDescriptor(Class<?> type, String name)

Constructs a value descriptor, useful for dynamically creating event types and annotations.

The following types are supported:

  • byte.class
  • short.class
  • int.class
  • long.class
  • char.class
  • float.class
  • double.class
  • boolean.class
  • String.class
  • Class.class
  • Thread.class

The name must be a valid Java identifier (for example, "maxThroughput"). See section 3.8 and 3.9 of the Java Language Specification for more information.

Parameters
type:Class<?>

the type, not null

name:String

the name, not null

Exceptions
IllegalArgumentException:
if the name is not a valid Java identifier
ValueDescriptorback to summary
public ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations)

Constructs a value descriptor, useful for dynamically creating event types and annotations.

The following types are supported:

  • byte.class
  • short.class
  • int.class
  • long.class
  • char.class
  • float.class
  • double.class
  • boolean.class
  • String.class
  • Class.class
  • Thread.class

The name must be a valid Java identifier (for example, "maxThroughput"). See section 3.8 and 3.9 of the Java Language Specification for more information.

Parameters
type:Class<?>

the type, not null

name:String

the name, not null

annotations:List<AnnotationElement>

the annotations on the value descriptors, not null

Exceptions
IllegalArgumentException:
if the name is not a valid Java identifier
ValueDescriptorback to summary
pack-priv ValueDescriptor(Class<?> type, String name, List<AnnotationElement> annotations, boolean allowArray)

Method Detail

getAnnotationback to summary
public <A extends Annotation> A getAnnotation(Class<A> annotationType)

Returns the first annotation for the specified type if an annotation element with the same name is directly present for this value descriptor, null otherwise.

Parameters
<A>
the type of the annotation to query for and return if present
annotationType:Class<A>

the Class object that corresponds to the annotation type, not null

Returns:A

this element's annotation for the specified annotation type if directly present, else null

getAnnotationElementsback to summary
public List<AnnotationElement> getAnnotationElements()

Returns an immutable list of annotation elements for this value descriptor.

Returns:List<AnnotationElement>

a list of annotations, not null

getContentTypeback to summary
public String getContentType()

Returns a textual identifier that specifies how a value represented by this ValueDescriptor is interpreted or formatted.

For example, if the value descriptor's type is float and the event value is 0.5f, a content type of "jdk.jfr.Percentage" hints to a client that the value is a percentage and that it should be rendered as "50%".

The JDK provides the following predefined content types:

  • jdk.jfr.Percentage
  • jdk.jfr.Timespan
  • jdk.jfr.Timestamp
  • jdk.jfr.Frequency
  • jdk.jfr.Flag
  • jdk.jfr.MemoryAddress
  • jdk.jfr.DataAmount
  • jdk.jfr.NetworkAddress

User-defined content types can be created by using the ContentType class.

Returns:String

the content type, or null if doesn't exist

See Also
ContentType
getDescriptionback to summary
public String getDescription()

Returns a sentence describing the value (for example, "Maximum throughput in the transaction system. Value is reset after each new batch.").

Returns:String

the description, or null if doesn't exist

getFieldsback to summary
public List<ValueDescriptor> getFields()

Returns an immutable list of value descriptors if the type is complex, else an empty list.

Returns:List<ValueDescriptor>

a list of value descriptors, not null

getJavaFieldNameback to summary
pack-priv String getJavaFieldName()
getLabelback to summary
public String getLabel()

Returns a human-readable name that describes the value (for example, "Maximum Throughput").

Returns:String

a human-readable name, or null if doesn't exist

getNameback to summary
public String getName()

Returns the name of the value (for example, "maxThroughput").

Returns:String

the name, not null

getTypeback to summary
pack-priv Type getType()
getTypeIdback to summary
public long getTypeId()

Returns a unique ID for the type in the Java virtual Machine (JVM). The ID might not be the same between JVM instances.

Returns:long

the type ID, not negative

getTypeNameback to summary
public String getTypeName()

Returns the fully qualified class name of the type that is associated with this value descriptor.

Returns:String

the type name, not null

See Also
ValueDescriptor#getTypeId()
isArrayback to summary
public boolean isArray()

Returns if this value descriptor is an array type.

Returns:boolean

true if it is an array type, false otherwise

isConstantPoolback to summary
pack-priv boolean isConstantPool()
isUnsignedback to summary
pack-priv boolean isUnsigned()
setAnnotationsback to summary
pack-priv void setAnnotations(List<AnnotationElement> anno)