--- old/src/java.base/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java 2019-05-28 09:48:27.283582785 -0700 +++ new/src/java.base/share/classes/sun/reflect/annotation/AnnotatedTypeFactory.java 2019-05-28 09:48:26.859370785 -0700 @@ -393,29 +393,22 @@ return (TypeVariable)getType(); } - // For toString, the declaration of a type variable should + // The declaration of a type variable should // including information about its bounds, etc. However, the // use of a type variable should not. For that reason, it is - // acceptable for the toString implementation of + // acceptable for the toString and hashCode implementations of // AnnotatedTypeVariableImpl to use the inherited - // implementation from AnnotatedTypeBaseImpl. + // implementations from AnnotatedTypeBaseImpl. @Override public boolean equals(Object o) { if (o instanceof AnnotatedTypeVariable) { AnnotatedTypeVariable that = (AnnotatedTypeVariable) o; - return equalsTypeAndAnnotations(that) && - Arrays.equals(getAnnotatedBounds(), that.getAnnotatedBounds()); + return equalsTypeAndAnnotations(that); } else { return false; } } - - @Override - public int hashCode() { - return baseHashCode() ^ - Objects.hash((Object[])getAnnotatedBounds()); - } } private static final class AnnotatedParameterizedTypeImpl extends AnnotatedTypeBaseImpl --- old/test/jdk/java/lang/annotation/typeAnnotations/TestObjectMethods.java 2019-05-28 09:48:28.099990785 -0700 +++ new/test/jdk/java/lang/annotation/typeAnnotations/TestObjectMethods.java 2019-05-28 09:48:27.659770785 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,7 +23,7 @@ /* * @test - * @bug 8058202 8212081 + * @bug 8058202 8212081 8224012 * @summary Test java.lang.Object methods on AnnotatedType objects. */ @@ -72,6 +72,8 @@ testGetAnnotations(AnnotatedTypeHost.class, true); testWildcards(); + + testFbounds(); if (errors > 0) { throw new RuntimeException(errors + " errors"); @@ -303,6 +305,7 @@ } } + private static AnnotatedWildcardType extractWildcard(String methodName) { try { return (AnnotatedWildcardType) @@ -314,6 +317,23 @@ } } + static void testFbounds() { + // Make sure equals and hashCode work fine for a type + // involving an F-bound, in particular Comparable in + // java.lang.Enum: + // + // class Enum> + // implements Constable, Comparable, Serializable + + AnnotatedType[] types = Enum.class.getAnnotatedInterfaces(); + + for (int i = 0; i < types.length; i ++) { + for (int j = 0; j < types.length; j ++) { + checkTypesForEquality(types[i], types[j], i == j); + } + } + } + // The TypeHost and AnnotatedTypeHost classes declare methods with // the same name and signatures but with the AnnotatedTypeHost // methods having annotations on their return type, where