@Test public void testHasAnnotationJavassist() throws Exception { ClassPool ctPool = ClassPool.getDefault(); CtClass ctClass = ctPool.getCtClass(AnonymousClassPatchPlugin.class.getName()); assertTrue(AnnotationHelper.hasAnnotation(ctClass, "org.hotswap.agent.annotation.Plugin")); assertFalse(AnnotationHelper.hasAnnotation(ctClass, "xxxx")); }
public static boolean hasAnnotation(Class clazz, String annotationClass) { for (Annotation annot : clazz.getDeclaredAnnotations()) if (annot.annotationType().getName().equals(annotationClass)) return true; return false; }
AnnotationHelper { public static boolean hasAnnotation(Class clazz, String annotationClass) { for (Annotation annot : clazz.getDeclaredAnnotations()) if (annot.annotationType().getName().equals(annotationClass)) return true; return false; } }
AnnotationHelper { public static boolean hasAnnotation(Class clazz, String annotationClass) { for (Annotation annot : clazz.getDeclaredAnnotations()) if (annot.annotationType().getName().equals(annotationClass)) return true; return false; }  }
AnnotationHelper { public static boolean hasAnnotation(Class clazz, String annotationClass) { for (Annotation annot : clazz.getDeclaredAnnotations()) if (annot.annotationType().getName().equals(annotationClass)) return true; return false; }  static boolean hasAnnotation(Class clazz, String annotationClass); static boolean hasAnnotation(CtClass clazz, String annotationClass); }
AnnotationHelper { public static boolean hasAnnotation(Class clazz, String annotationClass) { for (Annotation annot : clazz.getDeclaredAnnotations()) if (annot.annotationType().getName().equals(annotationClass)) return true; return false; }  static boolean hasAnnotation(Class clazz, String annotationClass); static boolean hasAnnotation(CtClass clazz, String annotationClass);  }