Usually it is considered that default Object.hashCode and System.identityHashCode are calculated as value converted of object address to int. But this is not a strict rule. In fact in JVM8 there are possibilities to choose the implementation of Object.hashCode with option -XX:hashCode=0..5. The list of functions can be found at http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/tip/src/share/vm/runtime/synchronizer.cpp in method get_next_hash. Here is the list of possible values:
0 - unguarded global Park-Miller RNG;
1 - function on bits;
2 - constant 1;
3 - sequence number;
4 - object address;
5 - Marsaglia's xor-shift scheme with thread-specific state.
In JVM 8 by default is used Margalia's xor-shift option. See http://hg.openjdk.java.net/jdk8/jdk8/hotspot/file/87ee5ee27509/src/share/vm/runtime/globals.hpp and line:
product(intx, hashCode, 5,"(Unstable) select hashCode generation algorithm").
Комментариев нет:
Отправить комментарий