aspose file tools*
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Local parameter by value vs. reference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Local parameter by value vs. reference?" Watch "Local parameter by value vs. reference?" New topic
Author

Local parameter by value vs. reference?

Joseph Edward
Greenhorn

Joined: Sep 15, 2004
Posts: 19
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
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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

Joined: Sep 15, 2004
Posts: 19
Thank you Kathy, it�s all clear now

Edward
 
 
subject: Local parameter by value vs. reference?