diff --git a/core/src/main/java/dagger/internal/loaders/ReflectiveAtInjectBinding.java b/core/src/main/java/dagger/internal/loaders/ReflectiveAtInjectBinding.java index 08f0264c31d..f5c41ccb1b5 100644 --- a/core/src/main/java/dagger/internal/loaders/ReflectiveAtInjectBinding.java +++ b/core/src/main/java/dagger/internal/loaders/ReflectiveAtInjectBinding.java @@ -25,7 +25,9 @@ import java.lang.reflect.Modifier; import java.lang.reflect.Type; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Set; import javax.inject.Inject; @@ -148,7 +150,14 @@ public static Binding create(Class type, boolean mustHaveInjections) { // Lookup the injectable fields and their corresponding keys. List injectedFields = new ArrayList(); for (Class c = type; c != Object.class; c = c.getSuperclass()) { - for (Field field : c.getDeclaredFields()) { + Field[] fields = c.getDeclaredFields(); + Arrays.sort(fields, new Comparator() { + @Override + public int compare(Object a, Object b) { + return a.toString().compareTo(b.toString()); + } + }); + for (Field field : fields) { if (!field.isAnnotationPresent(Inject.class) || Modifier.isStatic(field.getModifiers())) { continue; }