static <A extends Annotation> void removeAnnotation(CtMethod<?> method, Class<A> annClass) { CtAnnotation<?> toRemove = null; for (CtAnnotation<? extends Annotation> ctAnnotation : method.getAnnotations()) { if (annClass.isAssignableFrom(ctAnnotation.getActualAnnotation().getClass())) { toRemove = ctAnnotation; break; } } if (toRemove != null) method.removeAnnotation(toRemove); }