get object from memory by hash code

后端 未结 2 1106
抹茶落季
抹茶落季 2020-12-30 16:18

My question is relate to security level of JVM

How we can we get the object from memory by proving hash code?

Today i was thinking. I create an object of

相关标签:
2条回答
  • 2020-12-30 16:42

    How we can we get the object from memory by proving hash code?

    You can't without access to the internals of the JVM. Even then you would need to scan every object in memory. You would also have the problem than multiple objects with the same hashCode. BTW: By default objects don't have a hashCode until you ask for one.

    I think it is possible. Because when I execute environment one. Again and again i get that JVM return the same hash code.

    This only works because you are recreating the exact conditions where the hashCode as generated, the slightest changes and you would get different hashCodes.

    Means it first find the object in its cache. If it get the reference, it just return it.

    By it you mean a cache you would need to maintain, no such cache exists in the 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.

    The reference is passed, like you said. Nothing else.

    0 讨论(0)
  • 2020-12-30 16:43

    I guess it is irrelevant since hash code may or may not be related to memory address take a look documentation

    in general each JVM has its own memory stack so whether you can access object from other JVM is depending on JVM implementation and I guess it is rarely possible.

    0 讨论(0)
提交回复
热议问题