diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionArrayProjectionTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionArrayProjectionTest.java index 1497239225..816197fe00 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionArrayProjectionTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionArrayProjectionTest.java @@ -7,6 +7,9 @@ import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Comparator; import static org.mockito.Mockito.mock; @@ -35,7 +38,15 @@ protected TypeDescription.Generic describeParameterType(Method method, int index } protected TypeDescription.Generic describeExceptionType(Method method, int index) { - return TypeDefinition.Sort.describe(method.getGenericExceptionTypes()[index], + Type[] genericExceptionTypes = method.getGenericExceptionTypes(); + Arrays.sort(genericExceptionTypes, new Comparator() { + @Override + public int compare(Type type, Type t1) { + return type.getTypeName().compareTo(t1.getTypeName()); + } + }); + + return TypeDefinition.Sort.describe(genericExceptionTypes[index], new TypeDescription.Generic.AnnotationReader.Delegator.ForLoadedExecutableExceptionType(method, index)); } diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionGenericBuilderTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionGenericBuilderTest.java index 6d9e4924ee..aee30fac79 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionGenericBuilderTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/description/type/TypeDescriptionGenericBuilderTest.java @@ -12,7 +12,9 @@ import java.lang.reflect.Method; import java.lang.reflect.Type; import java.lang.reflect.WildcardType; +import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.sameInstance; @@ -40,7 +42,15 @@ protected TypeDescription.Generic describeParameterType(Method method, int index } protected TypeDescription.Generic describeExceptionType(Method method, int index) { - return describe(method.getGenericExceptionTypes()[index], new TypeDescription.Generic.AnnotationReader.Delegator.ForLoadedExecutableExceptionType(method, index)) + Type[] genericExceptionTypes = method.getGenericExceptionTypes(); + Arrays.sort(genericExceptionTypes, new Comparator() { + @Override + public int compare(Type type, Type t1) { + return type.getTypeName().compareTo(t1.getTypeName()); + } + }); + + return describe(genericExceptionTypes[index], new TypeDescription.Generic.AnnotationReader.Delegator.ForLoadedExecutableExceptionType(method, index)) .accept(TypeDescription.Generic.Visitor.Substitutor.ForAttachment.of(new MethodDescription.ForLoadedMethod(method))); } diff --git a/byte-buddy-dep/src/test/java/net/bytebuddy/implementation/auxiliary/MethodCallProxyTest.java b/byte-buddy-dep/src/test/java/net/bytebuddy/implementation/auxiliary/MethodCallProxyTest.java index d1c56fb54c..0058b02a5f 100644 --- a/byte-buddy-dep/src/test/java/net/bytebuddy/implementation/auxiliary/MethodCallProxyTest.java +++ b/byte-buddy-dep/src/test/java/net/bytebuddy/implementation/auxiliary/MethodCallProxyTest.java @@ -6,7 +6,10 @@ import org.junit.Test; import java.lang.reflect.Constructor; +import java.lang.reflect.Field; import java.lang.reflect.Type; +import java.util.Arrays; +import java.util.Comparator; import java.util.concurrent.Callable; import static org.hamcrest.CoreMatchers.is; @@ -81,8 +84,15 @@ public void testNonGenericParameter() throws Exception { Class auxiliaryType = proxyOnlyDeclaredMethodOf(GenericType.class); assertThat(auxiliaryType.getTypeParameters().length, is(0)); assertThat(auxiliaryType.getDeclaredMethod("call").getGenericReturnType(), is((Type) Object.class)); - assertThat(auxiliaryType.getDeclaredFields()[1].getGenericType(), is((Type) Object.class)); - assertThat(auxiliaryType.getDeclaredFields()[2].getGenericType(), is((Type) Number.class)); + Field[] declaredFields = auxiliaryType.getDeclaredFields(); + Arrays.sort(declaredFields, new Comparator() { + @Override + public int compare(Field field1, Field field2) { + return field1.getName().compareTo(field2.getName()); + } + }); + assertThat(declaredFields[1].getGenericType(), is((Type) Object.class)); + assertThat(declaredFields[2].getGenericType(), is((Type) Number.class)); } @Test