jdk.jfr.Registered Java Examples

The following examples show how to use jdk.jfr.Registered. 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: EventInstrumentation.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
boolean isRegistered() {
    Boolean result = annotationValue(classNode, ANNOTATION_TYPE_REGISTERED.getDescriptor(), Boolean.class);
    if (result != null) {
        return result.booleanValue();
    }
    if (superClass != null) {
        Registered r = superClass.getAnnotation(Registered.class);
        if (r != null) {
            return r.value();
        }
    }
    return true;
}
 
Example #2
Source File: TestEventFactoryRegistration.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 {
    // Create an unregistered event
    List<AnnotationElement> annotations = new ArrayList<>();
    annotations.add(new AnnotationElement(Registered.class, false));
    EventFactory factory = EventFactory.create(annotations, Collections.emptyList());

    try {
        factory.getEventType();
        Asserts.fail("Should not be able to get event type from an unregistered event");
    } catch(IllegalStateException ise) {
        // OK as expected
    }

    // Now, register the event
    factory.register();
    EventType eventType = factory.getEventType();
    verifyRegistered(factory.getEventType());


    // Now, unregister the event
    factory.unregister();

    verifyUnregistered(eventType);

    // Create a registered event
    factory = EventFactory.create(Collections.emptyList(), Collections.emptyList());

    eventType = factory.getEventType();
    Asserts.assertNotNull(eventType);

    verifyRegistered(eventType);

}
 
Example #3
Source File: EventInstrumentation.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
boolean isRegistered() {
    Boolean result = annotationValue(classNode, ANNOTATION_TYPE_REGISTERED.getDescriptor(), Boolean.class);
    if (result != null) {
        return result.booleanValue();
    }
    if (superClass != null) {
        Registered r = superClass.getAnnotation(Registered.class);
        if (r != null) {
            return r.value();
        }
    }
    return true;
}
 
Example #4
Source File: TestEventFactoryRegistration.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 {
    // Create an unregistered event
    List<AnnotationElement> annotations = new ArrayList<>();
    annotations.add(new AnnotationElement(Registered.class, false));
    EventFactory factory = EventFactory.create(annotations, Collections.emptyList());

    try {
        factory.getEventType();
        Asserts.fail("Should not be able to get event type from an unregistered event");
    } catch(IllegalStateException ise) {
        // OK as expected
    }

    // Now, register the event
    factory.register();
    EventType eventType = factory.getEventType();
    verifyRegistered(factory.getEventType());


    // Now, unregister the event
    factory.unregister();

    verifyUnregistered(eventType);

    // Create a registered event
    factory = EventFactory.create(Collections.emptyList(), Collections.emptyList());

    eventType = factory.getEventType();
    Asserts.assertNotNull(eventType);

    verifyRegistered(eventType);

}
 
Example #5
Source File: EventInstrumentation.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
boolean isRegistered() {
    Boolean result = annotationValue(classNode, ANNOTATION_TYPE_REGISTERED.getDescriptor(), Boolean.class);
    if (result != null) {
        return result.booleanValue();
    }
    if (superClass != null) {
        Registered r = superClass.getAnnotation(Registered.class);
        if (r != null) {
            return r.value();
        }
    }
    return true;
}
 
Example #6
Source File: TestEventFactoryRegistration.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 {
    // Create an unregistered event
    List<AnnotationElement> annotations = new ArrayList<>();
    annotations.add(new AnnotationElement(Registered.class, false));
    EventFactory factory = EventFactory.create(annotations, Collections.emptyList());

    try {
        factory.getEventType();
        Asserts.fail("Should not be able to get event type from an unregistered event");
    } catch(IllegalStateException ise) {
        // OK as expected
    }

    // Now, register the event
    factory.register();
    EventType eventType = factory.getEventType();
    verifyRegistered(factory.getEventType());


    // Now, unregister the event
    factory.unregister();

    verifyUnregistered(eventType);

    // Create a registered event
    factory = EventFactory.create(Collections.emptyList(), Collections.emptyList());

    eventType = factory.getEventType();
    Asserts.assertNotNull(eventType);

    verifyRegistered(eventType);

}