Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Not A Problem
-
3.3.2
-
None
-
None
-
Windows 7, Java 6
Description
HashCodeBuilder.reflectionHashCode(Object object) returns always the same result for any array. The result is 17.
There is no information in javadoc, that this method works in that way.
The same situation in previous versions.
Example:
public class HashCodeBuilderTest { public static void main(String[] args) { System.out.println(HashCodeBuilder.reflectionHashCode(new double[] {1, 1})); System.out.println(HashCodeBuilder.reflectionHashCode(new double[] {2, 2})); System.out.println(HashCodeBuilder.reflectionHashCode(new int[] {3, 3})); System.out.println(HashCodeBuilder.reflectionHashCode(new int[] {4, 4})); System.out.println(HashCodeBuilder.reflectionHashCode(new Long[] {5L, 5L})); System.out.println(HashCodeBuilder.reflectionHashCode(new Double[] {null, null})); System.out.println(HashCodeBuilder.reflectionHashCode(new Object[] {Boolean.FALSE, 1L, null})); } }
Output:
17 17 17 17 17 17 17
Fix example 1
First check if argument obj in HashCodeBuilder.reflectionHashCode(Object obj) is an array and than use java.util.Arrays.hashCode(Object[] array)