JDK-8058202 introduced hashCode() and equals() methods for the inner class implementations of AnnotatedType.
The implementations of hashCode() accumulate the hash codes of its elements. But the data structures are cyclic, which makes this simple traversal an endless recursion.
The problem can be easily reproduced, for example with
public static void main(String[] args) {
Object[] intf = Enum.class.getAnnotatedInterfaces();
Objects.hash(intf);
}
The repeated stack trace elements in the StackOverflowError are
at java.base/sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedParameterizedTypeImpl.hashCode(AnnotatedTypeFactory.java:506)
at java.base/java.util.Arrays.hashCode(Arrays.java:4706)
at java.base/java.util.Objects.hash(Objects.java:147)
at java.base/sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeVariableImpl.hashCode(AnnotatedTypeFactory.java:417)
at java.base/java.util.Arrays.hashCode(Arrays.java:4706)
at java.base/java.util.Objects.hash(Objects.java:147)
at java.base/sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedParameterizedTypeImpl.hashCode(AnnotatedTypeFactory.java:506)
The implementations of equals() follow the same pattern as the implementations of hashCode() and therefore probably have the same problem.