| Author |
Instance of JVM and Serialization
|
Sudhanshu Mishra
Ranch Hand
Joined: May 28, 2011
Posts: 201
|
|
Hi all,
I am confused about the term "instance of jvm" referring to this statement in K&B.
"Clearly in Java it wouldn't make any sense to
save the actual value of a reference variable, because the value of a Java reference has
meaning only within the context of a single instance of a JVM."
Please make this statement clear.What does instance of JVM mean?
thanks....
|
 |
john price
Ranch Hand
Joined: Feb 24, 2011
Posts: 495
|
|
http://javabeanz.wordpress.com/2007/07/09/understanding-jvm/
http://www.artima.com/insidejvm/ed2/jvm.html
|
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
It means the actual JVM you have running at the moment. If you write java Foo or similar, you start a new instance of the JVM. The memory location of each object is different for different JVM instances.
|
 |
Sudhanshu Mishra
Ranch Hand
Joined: May 28, 2011
Posts: 201
|
|
Yes,I do agree.But when i created a class and its object,and tried to print the value of the reference variable,each and every time i got the same value for the reference variable.So,if the memory location of objact changes each time with new instances of jvm,how come the reference varaibles value is the same?
Does reference variable's value has anything to do with object's memory location?
Please reply...
|
 |
Ahmad Yazdankhah
Greenhorn
Joined: Jul 30, 2011
Posts: 8
|
|
To clarify your question, can you provide a piece of code?
|
 |
Sudhanshu Mishra
Ranch Hand
Joined: May 28, 2011
Posts: 201
|
|
Hey Ahmed,
thanks for having a look at the question.
Actually,I found out that,no,the value of reference variable and the value of object's memory address(obj.hashCode()) changes or may change with individual JVM instances.
|
 |
Sudhanshu Mishra
Ranch Hand
Joined: May 28, 2011
Posts: 201
|
|
Hi all,
One more thing to ask,does the object reference signifies in any way the object's memory location?
I guess it does,though i am not sure.
Please guide me through.
Thanks...
|
 |
 |
|
|
subject: Instance of JVM and Serialization
|
|
|