Module jdk.jfr
Package jdk.jfr

Class AnnotationElement

java.lang.Object
jdk.jfr.AnnotationElement

public final class AnnotationElement extends Object
Describes event metadata, such as labels, descriptions and units.

The following example shows how AnnotationElement can be used to dynamically define events.

List<AnnotationElement> typeAnnotations = new ArrayList<>();
typeAnnotations.add(new AnnotationElement(Name.class, "com.example.HelloWorld"));
typeAnnotations.add(new AnnotationElement(Label.class, "Hello World"));
typeAnnotations.add(new AnnotationElement(Description.class, "Helps programmer getting started"));

List<AnnotationElement> fieldAnnotations = new ArrayList<>();
fieldAnnotations.add(new AnnotationElement(Label.class, "Message"));

List<ValueDescriptor> fields = new ArrayList<>();
fields.add(new ValueDescriptor(String.class, "message", fieldAnnotations));

EventFactory f = EventFactory.create(typeAnnotations, fields);
Event event = f.newEvent();
event.commit();
Since:
9