diff --git a/src/machine.h b/src/machine.h index 559b665d6f..c73a11d0b3 100644 --- a/src/machine.h +++ b/src/machine.h @@ -2260,7 +2260,11 @@ markHashTaken(Thread* t, object o) inline uint32_t takeHash(Thread*, object o) { - return reinterpret_cast(o) / BytesPerWord; + // some broken code implicitly relies on System.identityHashCode + // always returning a non-negative number (e.g. old versions of + // com/sun/xml/bind/v2/util/CollisionCheckStack.hash), hence the "& + // 0x7FFFFFFF": + return (reinterpret_cast(o) / BytesPerWord) & 0x7FFFFFFF; } inline uint32_t