Java Code Examples for jdk.jfr.AnnotationElement#getAnnotation()

The following examples show how to use jdk.jfr.AnnotationElement#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: TestLabel.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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 2
Source File: TestExperimental.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(ExperimentalEvent.class);

    // @Experimental on event
    Experimental e = t.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental annotation on event");

    // @Experimental on annotation
    AnnotationElement a = Events.getAnnotationByName(t, ExperimentalAnnotation.class.getName());
    e = a.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on annotation");

    // @Experimental on field
    a = Events.getAnnotation(t.getField("experimentalField"), Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on field");
}
 
Example 3
Source File: TestDescription.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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: TestLabel.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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 5
Source File: TestExperimental.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(ExperimentalEvent.class);

    // @Experimental on event
    Experimental e = t.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental annotation on event");

    // @Experimental on annotation
    AnnotationElement a = Events.getAnnotationByName(t, ExperimentalAnnotation.class.getName());
    e = a.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on annotation");

    // @Experimental on field
    a = Events.getAnnotation(t.getField("experimentalField"), Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on field");
}
 
Example 6
Source File: TestDescription.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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: TestLabel.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 8
Source File: TestExperimental.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(ExperimentalEvent.class);

    // @Experimental on event
    Experimental e = t.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental annotation on event");

    // @Experimental on annotation
    AnnotationElement a = Events.getAnnotationByName(t, ExperimentalAnnotation.class.getName());
    e = a.getAnnotation(Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on annotation");

    // @Experimental on field
    a = Events.getAnnotation(t.getField("experimentalField"), Experimental.class);
    Asserts.assertTrue(e != null, "Expected @Experimental on field");
}
 
Example 9
Source File: TestDescription.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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 10
Source File: TestContentType.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        EventType t = EventType.getEventType(SunnyDay.class);
        AnnotationElement aMax = Events.getAnnotation(t.getField("max"), Temperature.class);
        ContentType cMax = aMax.getAnnotation(ContentType.class);
        if (cMax == null) {
            throw new Exception("Expected Temperature annotation for field 'max' to have meta annotation ContentType");
        }
        AnnotationElement aHours = Events.getAnnotation(t.getField("hours"), Timespan.class);
        ContentType cHours = aHours.getAnnotation(ContentType.class);
        Asserts.assertTrue(cHours != null, "Expected Timespan annotation for field 'hours' to have meta annotation ContentType");
    }
 
Example 11
Source File: TestRelational.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(UserEvent.class);
    ValueDescriptor field = t.getField("id");
    AnnotationElement userId = Events.getAnnotation(field, UserId.class);
    Relational r = userId.getAnnotation(Relational.class);
    Asserts.assertTrue(r != null, "Expected relational annotation to have annotation @Relational");
}
 
Example 12
Source File: TestContentType.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        EventType t = EventType.getEventType(SunnyDay.class);
        AnnotationElement aMax = Events.getAnnotation(t.getField("max"), Temperature.class);
        ContentType cMax = aMax.getAnnotation(ContentType.class);
        if (cMax == null) {
            throw new Exception("Expected Temperature annotation for field 'max' to have meta annotation ContentType");
        }
        AnnotationElement aHours = Events.getAnnotation(t.getField("hours"), Timespan.class);
        ContentType cHours = aHours.getAnnotation(ContentType.class);
        Asserts.assertTrue(cHours != null, "Expected Timespan annotation for field 'hours' to have meta annotation ContentType");
    }
 
Example 13
Source File: TestRelational.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(UserEvent.class);
    ValueDescriptor field = t.getField("id");
    AnnotationElement userId = Events.getAnnotation(field, UserId.class);
    Relational r = userId.getAnnotation(Relational.class);
    Asserts.assertTrue(r != null, "Expected relational annotation to have annotation @Relational");
}
 
Example 14
Source File: TestContentType.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {

        EventType t = EventType.getEventType(SunnyDay.class);
        AnnotationElement aMax = Events.getAnnotation(t.getField("max"), Temperature.class);
        ContentType cMax = aMax.getAnnotation(ContentType.class);
        if (cMax == null) {
            throw new Exception("Expected Temperature annotation for field 'max' to have meta annotation ContentType");
        }
        AnnotationElement aHours = Events.getAnnotation(t.getField("hours"), Timespan.class);
        ContentType cHours = aHours.getAnnotation(ContentType.class);
        Asserts.assertTrue(cHours != null, "Expected Timespan annotation for field 'hours' to have meta annotation ContentType");
    }
 
Example 15
Source File: TestRelational.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    EventType t = EventType.getEventType(UserEvent.class);
    ValueDescriptor field = t.getField("id");
    AnnotationElement userId = Events.getAnnotation(field, UserId.class);
    Relational r = userId.getAnnotation(Relational.class);
    Asserts.assertTrue(r != null, "Expected relational annotation to have annotation @Relational");
}