Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Local parameter by value vs. reference?

 
Joseph Edward
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

On specification page 52, 5.3 Local Clientes, last paragraph:

"The arguments and results of the methods of the local interface and local home interface are passed by reference."

I found it a bit confusing, I think it�s by value.....Even when a reference is passed, it�s passed by value... or not?
And if an argument is a primitive?


Thanks
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is *really* bad terminology, and ironically, violates the way Sun officially describes the Java language semantics or pass-by-value. In the Java sense, local interfaces means that both the caller and the object being called are on the same heap, so it's just plain old Java pass-by-value (which as you mentioned, for object references you get the value (a copy) of the reference, and for primtives, you get a copy of the value of the primitive.

So, nothing is really pass-by-reference in the way that we use the term, but people use it differently, even within Sun.

Basically, it's something like this:

* When passing an object to or from a REMOTE method call, you pass a copy of the OBJECT.

* When passing an object to or from a LOCAL method call, you pass a copy of the REFERENCE.

* For primitives, it makes no difference--you're always getting a copy of the value of the primitive.

cheers,
Kathy
 
Joseph Edward
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Kathy, it�s all clear now

Edward
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic