diff --git a/icu4j/main/classes/core/src/com/ibm/icu/util/ByteArrayWrapper.java b/icu4j/main/classes/core/src/com/ibm/icu/util/ByteArrayWrapper.java index e39fdd07cf..1c2c75c964 100644 --- a/icu4j/main/classes/core/src/com/ibm/icu/util/ByteArrayWrapper.java +++ b/icu4j/main/classes/core/src/com/ibm/icu/util/ByteArrayWrapper.java @@ -237,7 +237,7 @@ public class ByteArrayWrapper implements Comparable */ @Override public int hashCode() { - int result = bytes.length; + int result = size; for (int i = 0; i < size; ++i) { result = 37*result + bytes[i]; } diff --git a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java index 7cfc9815e6..0613c2ddc4 100644 --- a/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java +++ b/icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/UtilityTest.java @@ -137,10 +137,10 @@ public class UtilityTest extends TestFmwk { } // test equality - if (!x.equals(y) || !x.equals(z)) - errln("FAIL: test (operator ==): Failed!"); - if (x.hashCode()!=y.hashCode()) - errln("FAIL: identical objects have different hash codes."); + assertEquals("x==y", x, y); + assertEquals("y==z", y, z); + assertEquals("x.hashCode()==y.hashCode()", x.hashCode(), y.hashCode()); + assertEquals("y.hashCode()==z.hashCode()", y.hashCode(), z.hashCode()); // test non-equality y = new ByteArrayWrapper(bb, 4);