• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Instance of JVM and Serialization

 
Ranch Hand
Posts: 238
1
Eclipse IDE Fedora Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://javabeanz.wordpress.com/2007/07/09/understanding-jvm/
http://www.artima.com/insidejvm/ed2/jvm.html
 
Marshal
Posts: 80267
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic