Update run-test 031-class-attributes
Ensure types are printed in alphabetical order.
Bug: 19499481
Change-Id: Ia14d2529f8031bc4c2bfb8911fdebebf97638dc9
diff --git a/test/031-class-attributes/expected.txt b/test/031-class-attributes/expected.txt
index 4ae1eed..de99872 100644
--- a/test/031-class-attributes/expected.txt
+++ b/test/031-class-attributes/expected.txt
@@ -33,8 +33,8 @@
enclosingMeth: null
modifiers: 1
package: null
- declaredClasses: [10] class ClassAttrs$PublicMemberClass, class ClassAttrs$MemberClass, interface ClassAttrs$PackagePrivateInnerInterface, interface ClassAttrs$PrivateInnerInterface, interface ClassAttrs$ProtectedInnerInterface, interface ClassAttrs$PublicInnerInterface, class ClassAttrs$PackagePrivateInnerClass, class ClassAttrs$PrivateInnerClass, class ClassAttrs$ProtectedInnerClass, class ClassAttrs$PublicInnerClass
- member classes: [3] class ClassAttrs$PublicMemberClass, interface ClassAttrs$PublicInnerInterface, class ClassAttrs$PublicInnerClass
+ declaredClasses: [10] class ClassAttrs$MemberClass, class ClassAttrs$PackagePrivateInnerClass, class ClassAttrs$PrivateInnerClass, class ClassAttrs$ProtectedInnerClass, class ClassAttrs$PublicInnerClass, class ClassAttrs$PublicMemberClass, interface ClassAttrs$PackagePrivateInnerInterface, interface ClassAttrs$PrivateInnerInterface, interface ClassAttrs$ProtectedInnerInterface, interface ClassAttrs$PublicInnerInterface
+ member classes: [3] class ClassAttrs$PublicInnerClass, class ClassAttrs$PublicMemberClass, interface ClassAttrs$PublicInnerInterface
isAnnotation: false
isAnonymous: false
isArray: false
diff --git a/test/031-class-attributes/src/ClassAttrs.java b/test/031-class-attributes/src/ClassAttrs.java
index ae8b2f5..977a05f 100644
--- a/test/031-class-attributes/src/ClassAttrs.java
+++ b/test/031-class-attributes/src/ClassAttrs.java
@@ -9,6 +9,9 @@
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
public class ClassAttrs {
ClassAttrs() {
@@ -323,19 +326,27 @@
* Convert an array of Type into a string. Start with an array count.
*/
private static String stringifyTypeArray(Type[] types) {
+ List<String> typeStringList = new ArrayList<String>();
+ for (Type t : types) {
+ typeStringList.add(t.toString());
+ }
+ // Sort types alphabetically so they're always printed in the same order, whichever
+ // tool generated the DEX file of the test.
+ Collections.sort(typeStringList);
+
StringBuilder stb = new StringBuilder();
boolean first = true;
stb.append("[" + types.length + "]");
- for (Type t: types) {
+ for (String typeString : typeStringList) {
if (first) {
stb.append(" ");
first = false;
} else {
stb.append(", ");
}
- stb.append(t.toString());
+ stb.append(typeString);
}
return stb.toString();