-
Bug
-
Resolution: Fixed
-
P2
-
12, 13
-
None
-
b23
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8225845 | 14 | Joe Darcy | P2 | Resolved | Fixed | team |
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.
- backported by
-
JDK-8225845 AnnotatedType implementations of hashCode() lead to StackOverflowError
- Resolved
- relates to
-
JDK-8058202 AnnotatedType implementations don't override toString(), equals(), hashCode()
- Closed