/** * Returns an {@link Iterator} over a {@link Collection} of Throwable types which iterates over * its elements in a consistent order (maintaining an ordering that is consistent across different * runs makes it easier to compare sets generated by different implementations of the CFG * classes). * * @param coll The collection to iterate over. * @return An iterator which presents the elements of <code>coll</code> in order. */ private static Iterator sortedThrowableIterator(Collection coll) { if (coll.size() <= 1) { return coll.iterator(); } else { Object array[] = coll.toArray(); Arrays.sort(array, new ThrowableComparator()); return Arrays.asList(array).iterator(); } }