Program: 11295
Project: 11295
Buggy source:
/** 
 * This method scans the provided class, its superclasses and interfaces for all supported   {@code} {@link Annotation} : {@link AnnotatedObject} pairs.These are then cached to remove the need for future queries. <p> By combining multiple  {@code Annotation : AnnotatedObject} pairs in onequery, we can limit the number of times a class's superclass and interface hierarchy are traversed. </p>
 * @param scannedClass Class to scan
 * @param query Pairs of {@link Annotation} and {@link AnnotatedObject}s to discover.
 */
public static void cacheAnnotatedObjects(final Class<?> scannedClass,final Query query){
synchronized (scannedClass) {
    if (scannedClass == null || scannedClass == Object.class)     return;
    final Set<Class<? extends Annotation>> keysToDrop=new HashSet<Class<? extends Annotation>>();
    for (    final Class<? extends Annotation> annotationClass : query.keySet()) {
      if (fieldCache.getList(scannedClass,annotationClass) != null) {
        keysToDrop.add(annotationClass);
      }
 else       if (methodCache.getList(scannedClass,annotationClass) != null) {
        keysToDrop.add(annotationClass);
      }
    }
    for (    final Class<? extends Annotation> key : keysToDrop) {
      query.remove(key);
    }
    if (query.isEmpty())     return;
    final List<Class<?>> inherited=new ArrayList<Class<?>>();
    final Class<?> superClass=scannedClass.getSuperclass();
    if (superClass != null) {
      cacheAnnotatedObjects(superClass,new Query(query));
      inherited.add(superClass);
    }
    for (    final Class<?> ifaceClass : scannedClass.getInterfaces()) {
      cacheAnnotatedObjects(ifaceClass,new Query(query));
      inherited.add(ifaceClass);
    }
    for (    final Class<? extends Annotation> annotationClass : query.keySet()) {
      final Class<? extends AnnotatedElement> objectClass=query.get(annotationClass);
      if (Method.class.isAssignableFrom(objectClass)) {
        populateCache(scannedClass,inherited,annotationClass,methodCache,scannedClass.getDeclaredMethods());
      }
 else       if (Field.class.isAssignableFrom(objectClass)) {
        populateCache(scannedClass,inherited,annotationClass,fieldCache,scannedClass.getDeclaredFields());
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * This method scans the provided class, its superclasses and interfaces for all supported   {@link Annotation} : {@link AnnotatedObject} pairs.These are then cached to remove the need for future queries. <p> By combining multiple  {@code Annotation : AnnotatedObject} pairs in onequery, we can limit the number of times a class's superclass and interface hierarchy are traversed. </p>
 * @param scannedClass Class to scan
 * @param query Pairs of {@link Annotation} and {@link AnnotatedObject}s to discover.
 */
public static void cacheAnnotatedObjects(final Class<?> scannedClass,final Query query){
synchronized (scannedClass) {
    if (scannedClass == null || scannedClass == Object.class)     return;
    final Set<Class<? extends Annotation>> keysToDrop=new HashSet<Class<? extends Annotation>>();
    for (    final Class<? extends Annotation> annotationClass : query.keySet()) {
      if (fieldCache.getList(scannedClass,annotationClass) != null) {
        keysToDrop.add(annotationClass);
      }
 else       if (methodCache.getList(scannedClass,annotationClass) != null) {
        keysToDrop.add(annotationClass);
      }
    }
    for (    final Class<? extends Annotation> key : keysToDrop) {
      query.remove(key);
    }
    if (query.isEmpty())     return;
    final List<Class<?>> inherited=new ArrayList<Class<?>>();
    final Class<?> superClass=scannedClass.getSuperclass();
    if (superClass != null) {
      cacheAnnotatedObjects(superClass,new Query(query));
      inherited.add(superClass);
    }
    for (    final Class<?> ifaceClass : scannedClass.getInterfaces()) {
      cacheAnnotatedObjects(ifaceClass,new Query(query));
      inherited.add(ifaceClass);
    }
    for (    final Class<? extends Annotation> annotationClass : query.keySet()) {
      final Class<? extends AnnotatedElement> objectClass=query.get(annotationClass);
      if (Method.class.isAssignableFrom(objectClass)) {
        populateCache(scannedClass,inherited,annotationClass,methodCache,scannedClass.getDeclaredMethods());
      }
 else       if (Field.class.isAssignableFrom(objectClass)) {
        populateCache(scannedClass,inherited,annotationClass,fieldCache,scannedClass.getDeclaredFields());
      }
    }
  }
}