B@61de33
这是一个toString的返回;
61de33是十六进制的hashcode。
如何通过这个计算出对象的真正首地址。
期待高手。。
这是一个toString的返回;
61de33是十六进制的hashcode。
如何通过这个计算出对象的真正首地址。
期待高手。。
解决方案 »
- main函数传进来的参数怎么传到别的类并在别的类赋值?
- java输出的问题
- J2SE开发蓝牙问题
- 用动态代码来批量验证Http代理问题[有点难度,感兴趣的进来看看吧,100分]
- cvsnt-2.5.01和eclipse的配置问题。!!
- 请教最短路径算法,急!
- 何为bad smell?
- 各位高手知道在JAVA中如何用一个名称创建一个对象实例,并调用其方法,注意:在编写代码时并不知要创建的对象的类名,也并不知方法名
- 再开一贴,帮忙解决:乱码问题(环境redhat linux + tomcat)明天结账(2002-9-10)
- 简单的问题!送给啦!怎样用java做一个记事本小程序。
- 广发英雄帖.. 加散分..求最佳解决方式. 大家集思广益哈... (单纯顶者无分.事先说好..).
- 请大虾们来看看,如何实现我正文的功能.关键字:JFreeChart,柱状图,CategoryDataset,ChartPanel,jDialog.
hashcode跟地址没有任何关系,而且对象内的方法也不会知道自己的地址,更不会通过地址算hashcode
如果是object,hashcode是地址算出来的。但是string覆盖了object的hashcode。所以他和地址毫无关系
HashCode只是用来在MAP中保存对象方便的
JNIEXPORT jint JNICALL
JVM_IHashCode(JNIEnv *env, jobject obj)
{
uint32_t tmp;
uint32_t rot_tmp; /* Effectively asserts that we've already called initializeObjectHash. */
sysAssert(rand1 != 0); /*
* Return value is (<obj ptr> & ~7)^rand1 + (<obj ptr> rot -3)^rand2.
* This mangles the pointer sufficiently that it should be pretty tough to
* guess it without access to rand1 and rand2. The mangling function
* (due to John Rose) is an automorphism. Thus, it's extremely
* unlikely to reduce the quality of the hash function (in terms of
* "bucket dispersion"). In fact, it loads the bits most likely to
* distinguish the object (roughly, those in 0xFF8) into the
* lowest-order bits of the hash code, and smears them around
* by about 3.5 bit positions.
*/
tmp = (uint32_t)DeRef(env, obj); rot_tmp = tmp >> 3 | tmp << (8*sizeof(uint32_t)-3);
tmp = ((tmp & ~7) ^ rand1) + (rot_tmp ^ rand2) + offsetForNull; /* Note: Previous two lines could be repeated to strengthen the result. */ return tmp;
/*
* Proof of automorphism: Since the low-order 3 bits of the result
* are exactly (rand1+((tmp >> 3)^rand2))&07, one can recover
* the bits tmp&070 given rand1, rand2 and the hash. Likewise,
* the next three bits of the result are exactly ((tmp&070)^rand1
* + ((tmp >> 6)^rand2))&070, so one can also recover the bits
* tmp&0700. This process may be repeated until all bits are
* recovered. The low bits tmp&7 may be treated as if they
* were recovered from the high bits of a 35-bit hash word.
*/
}看看hashcode是怎么根据地址算出来的。