[jdk8u-dev] RFR: 8310026: [8u] make java_lang_String::hash_code consistent across platforms
Zdenek Zambersky
zzambers at openjdk.org
Wed Jun 14 13:11:13 UTC 2023
`java_lang_String::hash_code` produces inconsistent results on different platforms, when `s` is `char*`. This is because on some platforms `char` is signed, while on others unsigned (resulting in `char` to be either zero-extended or sign-extended, when cast to `unsigned int`). This causes 1 tier1 test failure on aarch64.
Details:
This was discovered by examining one failing test (from tier1) present on aarch64 builds:
`test/serviceability/sa/jmap-hashcode/Test8028623.java`
Test was introduced by [JDK-8028623](https://bugs.openjdk.org/browse/JDK-8028623). However fix done there does not work on aarch64. Code was later fixed (newer jdks) in [hotspot part](https://github.com/openjdk/jdk11u-dev/commit/7af927f9c10923b61f746eb6e566bcda853dd95a) of [JDK-8141132](https://bugs.openjdk.org/browse/JDK-8141132) (JEP 254: Compact Strings).
Fix:
Fixed by backporting very small portion of JDK-8141132.
Testing:
tier1 (x86, x86_64, aarch64): OK (tested by GH and in rhel-8 aarch64 VM)
-------------
Commit messages:
- make hash_code consistent across platforms
Changes: https://git.openjdk.org/jdk8u-dev/pull/336/files
Webrev: https://webrevs.openjdk.org/?repo=jdk8u-dev&pr=336&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8310026
Stats: 13 lines in 3 files changed: 10 ins; 0 del; 3 mod
Patch: https://git.openjdk.org/jdk8u-dev/pull/336.diff
Fetch: git fetch https://git.openjdk.org/jdk8u-dev.git pull/336/head:pull/336
PR: https://git.openjdk.org/jdk8u-dev/pull/336
More information about the jdk8u-dev
mailing list