test/jdk/java/lang/annotation/typeAnnotations/TestObjectMethods.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52317 3c981e581f93
child 58679 9c3209ff7550
--- a/test/jdk/java/lang/annotation/typeAnnotations/TestObjectMethods.java	Thu Oct 17 20:27:44 2019 +0100
+++ b/test/jdk/java/lang/annotation/typeAnnotations/TestObjectMethods.java	Thu Oct 17 20:53:35 2019 +0100
@@ -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.
  */
 
@@ -73,6 +73,8 @@
 
         testWildcards();
 
+        testFbounds();
+
         if (errors > 0) {
             throw new RuntimeException(errors + " errors");
         }
@@ -175,7 +177,7 @@
         }
     }
 
-    private static final Pattern annotationRegex = Pattern.compile("@TestObjectMethods\\$AnnotType\\(value=(\\p{Digit})+\\)");
+    private static final Pattern annotationRegex = Pattern.compile("@TestObjectMethods\\$AnnotType\\((\\p{Digit})+\\)");
 
     static void testGetAnnotations(Class<?> clazz, boolean annotationsExpectedOnMethods) {
         System.err.println("Testing getAnnotations on methods of class " + clazz.getName());
@@ -314,6 +316,23 @@
         }
     }
 
+    static void testFbounds() {
+        // Make sure equals and hashCode work fine for a type
+        // involving an F-bound, in particular Comparable<E> in
+        // java.lang.Enum:
+        //
+        // class Enum<E extends Enum<E>>
+        // implements Constable, Comparable<E>, 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