Permalink
Browse files

If bytecode cannot be located or parsed, at least alpha sort.

  • Loading branch information...
1 parent b40493d commit 785a33b478d358e79a3b6592754ad9ec051e4278 Jesse Glick committed Sep 19, 2011
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/main/java/org/junit/internal/MethodSorter.java
@@ -7,6 +7,7 @@
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -25,18 +26,18 @@
* (non-)bug #7023180</a>
*/
public static Method[] getDeclaredMethods(Class<?> clazz) {
- final List<String> names;
+ List<String> names = Collections.emptyList();
Method[] methods = clazz.getDeclaredMethods();
try {
names = methodNamesAndDescriptors(clazz);
} catch (IOException x) {
// TODO report somehow?
- return methods;
}
+ final List<String> _names = names;
Arrays.sort(methods, new Comparator<Method>() {
@Override public int compare(Method m1, Method m2) {
- int i1 = names.indexOf(nameAndDescriptor(m1));
- int i2 = names.indexOf(nameAndDescriptor(m2));
+ int i1 = _names.indexOf(nameAndDescriptor(m1));
+ int i2 = _names.indexOf(nameAndDescriptor(m2));
return i1 != i2 ? i1 - i2 : m1.toString().compareTo(m2.toString());
}
});

0 comments on commit 785a33b

Please sign in to comment.