Program: 92316
Project: 92316
Buggy source:
/** 
 * Returns the interfaces implemented by the given class and assignable to the given base interface, or   {@code null} if none. If more than one interface extends the given base,then the most specialized interfaces are returned. For example if the given class implements both the  {@link Set} and {@link Collection} interfaces, then the returnedarray contains only the  {@code Set} interface.{@section Example}{@code getLeafInterfaces(ArrayList.class, Collection.class)} returns an array of length 1containing  {@code List.class}.
 * @param < T >  The type of the {@code baseInterface} class argument.
 * @param type A class for which the implemented interface is desired.
 * @param baseInterface The base type of the interface to search.
 * @return The leaf interfaces matching the given criterion, or {@code null} if none.If non-null, than the array is guaranteed to contain at least one element.
 */
@SuppressWarnings("String_Node_Str") public static <T>Class<? extends T>[] getLeafInterfaces(Class<?> type,final Class<T> baseInterface){
  int count=0;
  Class<?>[] types=null;
  while (type != null) {
    final Class<?>[] candidates=type.getInterfaces();
    next:     for (    final Class<?> candidate : candidates) {
      if (baseInterface == null || baseInterface.isAssignableFrom(candidate)) {
        for (int i=0; i < count; i++) {
          final Class<?> old=types[i];
          if (candidate.isAssignableFrom(old)) {
            continue next;
          }
          if (old.isAssignableFrom(candidate)) {
            types[i]=candidate;
            continue next;
          }
        }
        if (types == null) {
          types=candidates;
        }
        if (count >= types.length) {
          types=copyOf(types,types.length + candidates.length);
        }
        types[count++]=candidate;
      }
    }
    type=type.getSuperclass();
  }
  return (Class[])resize(types,count);
}

Fixed version (ground truth):
/** 
 * Returns the interfaces implemented by the given class and assignable to the given base interface, or an empty array if none. If more than one interface extends the given base, then the most specialized interfaces are returned. For example if the given class implements both the   {@link Set} and {@link Collection} interfaces, then the returnedarray contains only the  {@code Set} interface.{@section Example}{@code getLeafInterfaces(ArrayList.class, Collection.class)} returns an array of length 1containing  {@code List.class}.
 * @param < T >  The type of the {@code baseInterface} class argument.
 * @param type A class for which the implemented interfaces are desired.
 * @param baseInterface The base type of the interfaces to search.
 * @return The leaf interfaces matching the given criterion, or an empty array if none.
 */
@SuppressWarnings("String_Node_Str") public static <T>Class<? extends T>[] getLeafInterfaces(Class<?> type,final Class<T> baseInterface){
  int count=0;
  Class<?>[] types=EMPTY_ARRAY;
  while (type != null) {
    final Class<?>[] candidates=type.getInterfaces();
    next:     for (    final Class<?> candidate : candidates) {
      if (baseInterface == null || baseInterface.isAssignableFrom(candidate)) {
        for (int i=0; i < count; i++) {
          final Class<?> old=types[i];
          if (candidate.isAssignableFrom(old)) {
            continue next;
          }
          if (old.isAssignableFrom(candidate)) {
            types[i]=candidate;
            continue next;
          }
        }
        if (types == EMPTY_ARRAY) {
          types=candidates;
        }
        if (count >= types.length) {
          types=copyOf(types,types.length + candidates.length);
        }
        types[count++]=candidate;
      }
    }
    type=type.getSuperclass();
  }
  return (Class[])resize(types,count);
}