• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFE - Arguments and return types!!!

 
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi folks, in page 68 and 69 in HF EJB,it's mentioned that when you invoke a local method, a copy of reference is passed. whereas when a method invocation is remote, then a serialized copy of actual object is passed as opposed to a copy of a reference to the object. WHY? i don't get what would be the differences in passing a copy of reference to an object and a copy of an object itself? could you please explain it?
thanks.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Namaste,
If you know languages which have pointers (like C, C++, Pascal), it's easy to understand. A pointer owns some address in memory. You can see a reference to an object like a sort of pointer. A variable which carries an object's address on the heap. Such an address is local to the heap it's defined for.
When you pass a copy of a reference to a *local* method, the address is still meaningful because you're still in the same heap. But if you had to pass a reference (from one JVM / one heap) to a *remote* method (other JVM / other heap), the address received wouldn't be of any use : the referenced object doesn't exist in the remote heap (and even if it did exist, its "address" would be different).
That's why a copy of the object itself must be passed to a remote method.
Best,
Phil.
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks Phil for the prompt response. but i still have some difficulties in understanding what you just said:

Originally posted by Philippe Maquet:
Hi Namaste,
When you pass a copy of a reference to a *local* method, the address is still meaningful because you're still in the same heap.


how does being in the same heap make the address that is refereneced by a copy of a reference of an object meaningful?What is *meaningful* mean here?


But if you had to pass a reference (from one JVM / one heap) to a *remote* method (other JVM / other heap), the address received wouldn't be of any use : the referenced object doesn't exist in the remote heap (and even if it did exist, its "address" would be different).


how would that address be different even if the object did exit there? or what is the point whether the object exits or not? sorry for not being able to understand this simple but fundamental concept.
i would appreciate if you could explain it in layman terms.
thanks again.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Namaste,

how does being in the same heap make the address that is refereneced by a copy of a reference of an object meaningful?What is *meaningful* mean here?


It's not "the address that is refereneced by a copy of a reference", a reference (to an object) *is* an address (or sort of).

how would that address be different even if the object did exit there?


Let's say that you receive someone's address : Main Street 499 (address) in Santa Rosa (heap). But you're in another town (another heap). How will you find the house at Main Street 499 if you are in Brussels for instance. Maybe there is no Main Street in Brussels, or no #499, but even if this address exists there it will be another house, right ?

or what is the point whether the object exits or not?


The aim of passing a reference is to give access to the referenced object. If the latter doesn't exist, well you simply missed your goal.
Best,
Phil.
 
Brian Smith
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Philippe Maquet:
Hi Namaste,
Let's say that you receive someone's address : Main Street 499 (address) in Santa Rosa (heap). But you're in another town (another heap). How will you find the house at Main Street 499 if you are in Brussels for instance. Maybe there is no Main Street in Brussels, or no #499, but even if this address exists there it will be another house, right ?


Of course we can't find the Maint Street 499 in Satan Rosa (heap) in Brussels (another heap). then there has to be the same Stanta Rosa in Brussels there so that we can find the same the Maint Street 499 ? in another words, we need to pass the whole place (object) to find that same address?
thanks.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Namaste,
whereas when a method invocation is remote, then a serialized copy of actual object is passed as opposed to a copy of a reference to the object.
There is no remote and local methods. Only remote and local bean interfaces. Ok. You can have bean with both local and remote interfaces but Kathy and Bert say it's not what you want to do.
WHY? i don't get what would be the differences in passing a copy of reference to an object and a copy of an object itself? could you please explain it?
Because when you pass reference you pass something like address of object on your machine. The remote machine can not look into your address space. That is why object is passed as whole.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic