aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I am not getting K&B page 445 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I am not getting K&B page 445" Watch "I am not getting K&B page 445" New topic
Author

I am not getting K&B page 445

Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Dear sir i am not getting following paragraph of k&B page 445 that is

"In java it wouldn't make any sense to save the actual value of a refrence variable , because the value of java refrence has meaning only within the context of single instance of a jvm. In other words if you tried to restore the object in another instance of jvm, even running on the same computer on which the object was originally serialized, the refrence would be useles."

Hear what does mean by the instance of jvm,running on same or diffrence computer ?

plese clearify me.

with regard

Arun kumar maalik
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

An instance of the JVM represets a seperate process of execution. For example if you were to run your program twice simultaneously on the same machine then you are running two instances of the JVM on the same machine. Every instance is a seperate process


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
Two different instances of jvm means twice you are executing your program by java.

When you run java className, you get one instance of jvm.

What author is trying to say that simply passing the reference of a object which is class@hashCode to a different instance of jvm either running on the same machine or a remote machine will not copy the whole state of the object. If you can do so, then probably serialization will not come into the picture.

reference value is jvm instance specific. It has no meaning to a different jvm running on the same or a remote m/c.

Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Arun Maalik
Ranch Hand

Joined: Oct 25, 2005
Posts: 216
Thanks sir i have understood

Arun kumar maalik
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Naseem Khan:
...the reference of a object which is class@hashCode...

Not quite. In general, an object reference is a memory location, telling the JVM where to find the object. So obviously, this might be different with each execution.

(Remember, hashCode can be overridden to return any int, including a constant.)


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
In general, an object reference is a memory location, telling the JVM where to find the object


I agree with you. But if you print the reference, it gives class@hashCode. toString() method defined in Object class calls Integer.toHexString(hashCode()) and it converts hashCode value in hexadecimal representation.

It seems that even the reference point to an object on heap but still you can't get the memory address of the object by its reference.


- Naseem
[ August 27, 2006: Message edited by: Naseem Khan ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Naseem Khan:
...if you print the reference, it gives class@hashCode. toString() method defined in Object class calls Integer.toHexString(hashCode()) and it converts hashCode value in hexadecimal representation.

It seems that even the reference point to an object on heap but still you can't get the memory address of the object by its reference...

The toString method returns a String representation of the object. I don't know of a way to get at the actual reference value.
 
Consider Paul's rocket mass heater.
 
subject: I am not getting K&B page 445