Search in sources :

Example 1 with DebugExtension

use of com.ibm.j9ddr.tools.ddrinteractive.annotations.DebugExtension in project openj9 by eclipse.

the class DDRInteractiveClassLoader method examineClass.

/**
 * Check to see if a class has the version annotation and if so whether it matches the version of the currently
 * running vm.
 *
 * @param url
 * @param clazz
 */
@SuppressWarnings("unchecked")
private void examineClass(URL url, Class<?> clazz) {
    if (clazz.isAnnotationPresent(DebugExtension.class)) {
        Annotation a = clazz.getAnnotation(DebugExtension.class);
        if (null != a) {
            String value = ((DebugExtension) a).VMVersion();
            String[] versions = value.split(",");
            for (String version : versions) {
                if (version.equals(vmversion) || version.equals(VM_ALLVERSIONS)) {
                    if (hasCommandIFace(clazz)) {
                        PluginConfig config = new PluginConfig(clazz.getName(), vmversion, (Class<ICommand>) clazz, true, url);
                        pluginCache.add(config);
                        logger.fine("Added command " + clazz.getName());
                    } else {
                        logger.fine("Skipping annotated command which did not implement the ICommand interface : " + clazz.getName());
                    }
                } else {
                    String msg = String.format("Skipping %s as wrong VM version [allowed = %s, * : actual = %s]", clazz.getName(), vmversion, version);
                    logger.fine(msg);
                }
            }
        }
    }
}
Also used : DebugExtension(com.ibm.j9ddr.tools.ddrinteractive.annotations.DebugExtension) ICommand(com.ibm.j9ddr.tools.ddrinteractive.ICommand) Annotation(java.lang.annotation.Annotation)

Aggregations

ICommand (com.ibm.j9ddr.tools.ddrinteractive.ICommand)1 DebugExtension (com.ibm.j9ddr.tools.ddrinteractive.annotations.DebugExtension)1 Annotation (java.lang.annotation.Annotation)1