It is implemented in native code. As for the implementation, this is a little more complicated - you can change the default implementation. If you look at the sources of "Open JDK", you will see the following options:
-XX: hashCode = n (0 to 5).
- 0 - RNG Park-Miller (default)
- 1 - address function and some global state
- 2 - const 1
- 3 - sequential counter
- 4 - object address
- 5 - xor-shift
: http://hg.openjdk.java.net/jdk7/jdk7/hotspot/file/tip/src/share/vm/runtime/synchronizer.cpp
static inline intptr_t get_next_hash().