Object.hashCode() algorithm

前端 未结 4 1166
醉梦人生
醉梦人生 2020-12-17 15:45

I\'m looking for the algorithm of Object.hashCode().

This code is native in Object.java.

Is this because

(a) the code is in assemb

4条回答
  •  春和景丽
    2020-12-17 16:38

    hashCode is a native method, which means that a system library is called internally. This is because of the reason that hashcode internally will try to generate a number depending on the object memory location. This code is machine dependent and probably written in C.

    But if you are really interested to see the native code, then follow this:

    http://hg.openjdk.java.net/jdk7/jdk7-gate/jdk/file/e947a98ea3c1/src/share/native/java/

提交回复
热议问题