Hi,
Since your sb variable does not point to a remote object as defined by RMI,
there is no reason why it should be passed by reference. It is passed by copy,
and then both objects (the local one and the serverside one) follow an
independant life. If the sb variable was pointing to an RMI stub, things would
be different.
See the paragraph "Parameter Passing in Remote Method Invocation" in RMI specs :
http://java.sun.com/products/jdk/1.1/docs/guide/rmi/spec/rmi-objmodel.doc.html#2521
Regards, Alexandre Vauthey.
James Scott Stanlick wrote:
> I had a college friend present a situation to me yesterday that seems quite
> perplexing! Consider the following two java classes that run in a single
> JVM:
>
> class Huh {
>
> StringBuffer sb = new StringBuffer("Amit ");
>
> public Huh() {
> super();
> Huh2 h2 = new Huh2();
> h2.passIt(sb);
> System.out.println(sb);
> }
> public static void main(String[] args) {
> new Huh();
> }
> }
>
> class Huh2 {
> public void passIt(StringBuffer sb) {
> sb.append(" Stanlick");
> }
> }
>
> Output produced by class Huh is: Amit Stanlick.
>
> This suggests that the invoked method has the ability to modify the object
> passed to it as a parameter, which sounds very normal! The problem is where
> class Huh2 becomes a Session Bean. Class Huh can obtain a remote reference
> to Huh2 and fire the passIt(StringBuffer sb) method, however, the
> modification to the StringBuffer IS NOT reflected in Huh! This seems to
> defy the Java way! Can someone please explain?
>
> Thanks,
>
> J. Scott Stanlick
> Lead Software Engineer
> Enterprise Rent-A-Car
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff EJB-INTEREST". For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
--
**************************
Alexandre Vauthey
Software Engineer
Application Networks
1050 Chestnut street
Menlo Park, CA 94025
tel: (650) 462-7220
[EMAIL PROTECTED]
**************************
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".