Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Instance of JVM and Serialization

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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....
 
Ranch Hand
Posts: 495
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://javabeanz.wordpress.com/2007/07/09/understanding-jvm/
http://www.artima.com/insidejvm/ed2/jvm.html
 
Marshal
Posts: 69740
277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

To clarify your question, can you provide a piece of code?
 
Sudhanshu Mishra
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic