jdk.jfr.SettingControl Java Examples

The following examples show how to use jdk.jfr.SettingControl. 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: EventControl.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void defineSettings(Class<?> eventClass) {
    // Iterate up the class hierarchy and let
    // subclasses shadow base classes.
    boolean allowPrivateMethod = true;
    while (eventClass != null) {
        for (Method m : eventClass.getDeclaredMethods()) {
            boolean isPrivate = Modifier.isPrivate(m.getModifiers());
            if (m.getReturnType() == Boolean.TYPE && m.getParameterCount() == 1 && (!isPrivate || allowPrivateMethod)) {
                SettingDefinition se = m.getDeclaredAnnotation(SettingDefinition.class);
                if (se != null) {
                    Class<?> settingClass = m.getParameters()[0].getType();
                    if (!Modifier.isAbstract(settingClass.getModifiers()) && SettingControl.class.isAssignableFrom(settingClass)) {
                        String name = m.getName();
                        Name n = m.getAnnotation(Name.class);
                        if (n != null) {
                            name = n.value();
                        }
                        if (!eventControls.containsKey(name)) {
                            defineSetting((Class<? extends SettingControl>) settingClass, m, type, name);
                        }
                    }
                }
            }
        }
        eventClass = eventClass.getSuperclass();
        allowPrivateMethod = false;
    }
}
 
Example #2
Source File: EventControl.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void defineSettings(Class<?> eventClass) {
    // Iterate up the class hierarchy and let
    // subclasses shadow base classes.
    boolean allowPrivateMethod = true;
    while (eventClass != null) {
        for (Method m : eventClass.getDeclaredMethods()) {
            boolean isPrivate = Modifier.isPrivate(m.getModifiers());
            if (m.getReturnType() == Boolean.TYPE && m.getParameterCount() == 1 && (!isPrivate || allowPrivateMethod)) {
                SettingDefinition se = m.getDeclaredAnnotation(SettingDefinition.class);
                if (se != null) {
                    Class<?> settingClass = m.getParameters()[0].getType();
                    if (!Modifier.isAbstract(settingClass.getModifiers()) && SettingControl.class.isAssignableFrom(settingClass)) {
                        String name = m.getName();
                        Name n = m.getAnnotation(Name.class);
                        if (n != null) {
                            name = n.value();
                        }
                        if (!eventControls.containsKey(name)) {
                            defineSetting((Class<? extends SettingControl>) settingClass, m, type, name);
                        }
                    }
                }
            }
        }
        eventClass = eventClass.getSuperclass();
        allowPrivateMethod = false;
    }
}
 
Example #3
Source File: EventControl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private void defineSettings(Class<?> eventClass) {
    // Iterate up the class hierarchy and let
    // subclasses shadow base classes.
    boolean allowPrivateMethod = true;
    while (eventClass != null) {
        for (Method m : eventClass.getDeclaredMethods()) {
            boolean isPrivate = Modifier.isPrivate(m.getModifiers());
            if (m.getReturnType() == Boolean.TYPE && m.getParameterCount() == 1 && (!isPrivate || allowPrivateMethod)) {
                SettingDefinition se = m.getDeclaredAnnotation(SettingDefinition.class);
                if (se != null) {
                    Class<?> settingClass = m.getParameters()[0].getType();
                    if (!Modifier.isAbstract(settingClass.getModifiers()) && SettingControl.class.isAssignableFrom(settingClass)) {
                        String name = m.getName();
                        Name n = m.getAnnotation(Name.class);
                        if (n != null) {
                            name = n.value();
                        }
                        if (!eventControls.containsKey(name)) {
                            defineSetting((Class<? extends SettingControl>) settingClass, m, type, name);
                        }
                    }
                }
            }
        }
        eventClass = eventClass.getSuperclass();
        allowPrivateMethod = false;
    }
}