モジュール jdk.jfr
パッケージ jdk.jfr

クラスAnnotationElement

java.lang.Object
jdk.jfr.AnnotationElement

public final class AnnotationElement extends Object
ラベル、説明、ユニットなどのイベント・メタデータについて説明します。

次の例は、AnnotationElementを使用してイベントを動的に定義する方法を示しています。

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();

導入されたバージョン:
9