我的问题与 JVM 的安全级别有关
我们如何通过证明哈希码从内存中获取对象?
今天我在想。我在执行环境一中创建了一个 A 类对象。并从此处获取该对象的哈希码。
现在在另一个执行环境中,我想通过提供哈希码取回 A 类对象。
我觉得是可以的。因为当我执行环境一时。我一次又一次地得到 JVM 返回相同的哈希码。
意味着它首先在它的缓存中找到对象。如果它获得引用,它就返回它。
所以现在回到问题,我们必须了解当我们复制什么数据时 写=.
Object a=new Object();// here as we know reference of new object will be stored in refvar a.
然后实际通过的是什么。
如果我们得到=(等于运算符)传递的数据。我们将能够从内存中获取对象。
谢谢
最佳答案
How we can we get the object from memory by proving hash code?
您无法访问 JVM 的内部结构。即使那样,您也需要扫描内存中的每个对象。与具有相同 hashCode 的多个对象相比,您还会遇到问题。顺便说一句:默认情况下,对象没有哈希码,除非您要求一个。
I think it is possible. Because when I execute environment one. Again and again i get that JVM return the same hash code.
这之所以有效,是因为您正在重新创建生成 hashCode 的确切条件,最细微的变化,您将获得不同的 hashCode。
Means it first find the object in its cache. If it get the reference, it just return it.
它
是指您需要维护的缓存,JVM 中不存在这样的缓存。
So now back to question, we have to understand what data is copied when we write =.
Object a=new Object();// here as we know reference of new object will be stored in refvar a.
Then what in actual is passes through.
如您所说,引用已通过。没有别的。
关于java - 通过哈希码从内存中获取对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22323530/