From 0639acca21770abea6d62dffc7a455729e42eb60 Mon Sep 17 00:00:00 2001 From: hsestupin Date: Tue, 2 Jun 2020 16:15:50 +0200 Subject: [PATCH] add static hashCode(i) method like in java.lang.Integer --- .../main/java/org/teavm/classlib/java/lang/TInteger.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java b/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java index b407aaaf0..8f781ad3d 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java +++ b/classlib/src/main/java/org/teavm/classlib/java/lang/TInteger.java @@ -42,6 +42,10 @@ public class TInteger extends TNumber implements TComparable { return new TAbstractStringBuilder(20).append(i, radix).toString(); } + public static int hashCode(int value) { + return (value >>> 4) ^ (value << 28) ^ (value << 8) ^ (value >>> 24); + } + public static String toHexString(int i) { return toUnsignedLogRadixString(i, 4); } @@ -156,7 +160,7 @@ public class TInteger extends TNumber implements TComparable { @Override public int hashCode() { - return (value >>> 4) ^ (value << 28) ^ (value << 8) ^ (value >>> 24); + return TInteger.hashCode(value); } @Override