Java Code Examples for jdk.jfr.SettingDescriptor#getAnnotation()
The following examples show how to use
jdk.jfr.SettingDescriptor#getAnnotation() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestGetAnnotation.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Label al = annotatedType.getAnnotation(Label.class); Asserts.assertNull(al); // we should not inherit annotation from type Description ad = annotatedType.getAnnotation(Description.class); Asserts.assertNull(ad); // we should not inherit annotation from type Timestamp at = annotatedType.getAnnotation(Timestamp.class); Asserts.assertNull(at); // we should not inherit annotation from type SettingDescriptor newName = Events.getSetting(type, "newName"); Label nl = newName.getAnnotation(Label.class); Asserts.assertEquals(nl.value(), "Annotated Method"); Description nd = newName.getAnnotation(Description.class); Asserts.assertEquals(nd.value(), "Description of an annotated method"); Timespan nt = newName.getAnnotation(Timespan.class); Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); }
Example 2
Source File: TestLabel.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Event EventType t = EventType.getEventType(LabelEvent.class); Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); // Field ValueDescriptor field = t.getField("labledField"); Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); // Annotation AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); Label label = awl.getAnnotation(Label.class); Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); // Setting for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Label settingLabel = v.getAnnotation(Label.class); Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); } } }
Example 3
Source File: TestDescription.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(DescriptionEvent.class); // field description AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); String d = (String) aMax.getValue("value"); Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); // event description d = t.getAnnotation(Description.class).value(); Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); // annotation description AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); Description de = a.getAnnotation(Description.class); Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Description settingDescription = v.getAnnotation(Description.class); Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); } } }
Example 4
Source File: TestGetAnnotation.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Label al = annotatedType.getAnnotation(Label.class); Asserts.assertNull(al); // we should not inherit annotation from type Description ad = annotatedType.getAnnotation(Description.class); Asserts.assertNull(ad); // we should not inherit annotation from type Timestamp at = annotatedType.getAnnotation(Timestamp.class); Asserts.assertNull(at); // we should not inherit annotation from type SettingDescriptor newName = Events.getSetting(type, "newName"); Label nl = newName.getAnnotation(Label.class); Asserts.assertEquals(nl.value(), "Annotated Method"); Description nd = newName.getAnnotation(Description.class); Asserts.assertEquals(nd.value(), "Description of an annotated method"); Timespan nt = newName.getAnnotation(Timespan.class); Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); }
Example 5
Source File: TestLabel.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Event EventType t = EventType.getEventType(LabelEvent.class); Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); // Field ValueDescriptor field = t.getField("labledField"); Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); // Annotation AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); Label label = awl.getAnnotation(Label.class); Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); // Setting for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Label settingLabel = v.getAnnotation(Label.class); Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); } } }
Example 6
Source File: TestDescription.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(DescriptionEvent.class); // field description AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); String d = (String) aMax.getValue("value"); Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); // event description d = t.getAnnotation(Description.class).value(); Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); // annotation description AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); Description de = a.getAnnotation(Description.class); Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Description settingDescription = v.getAnnotation(Description.class); Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); } } }
Example 7
Source File: TestGetAnnotation.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType type = EventType.getEventType(CustomEvent.class); SettingDescriptor annotatedType = Events.getSetting(type, "annotatedType"); Label al = annotatedType.getAnnotation(Label.class); Asserts.assertNull(al); // we should not inherit annotation from type Description ad = annotatedType.getAnnotation(Description.class); Asserts.assertNull(ad); // we should not inherit annotation from type Timestamp at = annotatedType.getAnnotation(Timestamp.class); Asserts.assertNull(at); // we should not inherit annotation from type SettingDescriptor newName = Events.getSetting(type, "newName"); Label nl = newName.getAnnotation(Label.class); Asserts.assertEquals(nl.value(), "Annotated Method"); Description nd = newName.getAnnotation(Description.class); Asserts.assertEquals(nd.value(), "Description of an annotated method"); Timespan nt = newName.getAnnotation(Timespan.class); Asserts.assertEquals(nt.value(), Timespan.NANOSECONDS); }
Example 8
Source File: TestLabel.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { // Event EventType t = EventType.getEventType(LabelEvent.class); Asserts.assertEquals(t.getLabel(), "Event Label", "Incorrect label for event"); // Field ValueDescriptor field = t.getField("labledField"); Asserts.assertEquals(field.getLabel(), "Field Label", "Incorrect label for field"); // Annotation AnnotationElement awl = Events.getAnnotationByName(t, AnnotionWithLabel.class.getName()); Label label = awl.getAnnotation(Label.class); Asserts.assertEquals(label.value(), "Annotation Label", "Incorrect label for annotation"); // Setting for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Label settingLabel = v.getAnnotation(Label.class); Asserts.assertEquals(settingLabel.value(), "Setting Label", "Incorrect label for setting"); } } }
Example 9
Source File: TestDescription.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { EventType t = EventType.getEventType(DescriptionEvent.class); // field description AnnotationElement aMax = Events.getAnnotation(t.getField("field"), Description.class); String d = (String) aMax.getValue("value"); Asserts.assertEquals("Field Annotation", d, "Incorrect annotation for field, got '" + d + "'"); // event description d = t.getAnnotation(Description.class).value(); Asserts.assertEquals("Event Annotation", d, "Incorrect annotation for event, got '" + d + "'"); // annotation description AnnotationElement a = Events.getAnnotationByName(t, AnnotationWithDescription.class.getName()); Description de = a.getAnnotation(Description.class); Asserts.assertEquals("Meta Annotation", de.value(), "Incorrect annotation for event, got '" + de.value() + "'"); for (SettingDescriptor v: t.getSettingDescriptors()) { if (v.getName().equals("dummy")) { Description settingDescription = v.getAnnotation(Description.class); Asserts.assertEquals(settingDescription.value(), "Setting description", "Incorrect description for setting"); } } }