8224012: AnnotatedType implementations of hashCode() lead to StackOverflowError

Reviewed-by: jfranck
This commit is contained in:
Joe Darcy 2019-05-29 09:53:28 -07:00
parent 951e0b22d7
commit bc10b6aaff
2 changed files with 27 additions and 15 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -393,29 +393,22 @@ public final class AnnotatedTypeFactory {
return (TypeVariable)getType();
}
// For toString, the declaration of a type variable should
// including information about its bounds, etc. However, the
// The declaration of a type variable should
// include 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