You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/10/19 23:00:48 UTC
(commons-lang) 03/03: Strengthen TypeUtils hash code regression coverage
This is an automated email from the ASF dual-hosted git repository.
garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
commit 2341c9cd7ed4b7f2e841e165b6077d1aa7a61b17
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Oct 19 19:00:38 2026 -0400
Strengthen TypeUtils hash code regression coverage
Add upper-bounded wildcard cases for List<? extends Number> and
List<? extends T[]> to the JDK hash interoperability tests. Compare
the generic array hash directly with its reflected JDK counterpart.
---
src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
index 4cef509d9..0acb81b58 100644
--- a/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
+++ b/src/test/java/org/apache/commons/lang3/reflect/TypeUtilsTest.java
@@ -364,6 +364,8 @@ private static class HashCodeTypes<T> {
T[][] nestedArray;
List<String>[][] nestedListArray;
ParameterizedOwner<String>.NonGenericInner nonGenericMember;
+ List<? extends T[]> upperBoundedArrayArgument;
+ List<? extends Number> upperBoundedList;
List<T> variableList;
List<? super T[]> wildcardArrayArgument;
List<?> wildcardList;
@@ -520,6 +522,8 @@ static Stream<Arguments> testHashCodeMatchesJdk() {
Arguments.of("nestedListArray", TypeUtils.genericArrayType(TypeUtils.genericArrayType(strings))),
Arguments.of("nonGenericMember", TypeUtils.parameterizeWithOwner(TypeUtils.parameterize(ParameterizedOwner.class, String.class),
ParameterizedOwner.NonGenericInner.class)),
+ Arguments.of("upperBoundedArrayArgument", TypeUtils.parameterize(List.class, TypeUtils.wildcardType().withUpperBounds(array).build())),
+ Arguments.of("upperBoundedList", TypeUtils.parameterize(List.class, TypeUtils.wildcardType().withUpperBounds(Number.class).build())),
Arguments.of("variableList", TypeUtils.parameterize(List.class, variable)),
Arguments.of("wildcardArrayArgument", TypeUtils.parameterize(List.class, TypeUtils.wildcardType().withLowerBounds(array).build())),
Arguments.of("wildcardList", TypeUtils.parameterize(List.class, TypeUtils.WILDCARD_ALL)));
@@ -1047,7 +1051,7 @@ void testGenericArrayType() throws NoSuchFieldException {
.genericArrayType(TypeUtils.parameterize(Comparable.class, TypeUtils.wildcardType().withUpperBounds(Integer.class).build()));
assertTrue(TypeUtils.equals(expected, actual));
assertEquals("java.lang.Comparable<? extends java.lang.Integer>[]", actual.toString());
- assertNotEquals(0, actual.hashCode());
+ assertEquals(expected.hashCode(), actual.hashCode());
assertEquals(actual, actual);
assertFalse(actual.equals(null));
assertFalse(actual.equals(TypeUtils.wildcardType().build()));