| 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: 6588
|
|
|
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 - SCJP Mocks - SCJP 5 Mock exam (Word document ) - SCJP 5 Mock exam in Java.Inquisition format
|
 |
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.
|
 |
 |
|
|
subject: I am not getting K&B page 445
|
|
|