Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As others have already mentioned, when passing objects as parameters to an RMI method, the object will get serialized, then deserialized on the other end inside the target object containing the RMI method. This breaks the reference from the original objects passed in, as you now have two distinct objects: one in the client code calling the method, and one on the remote side.</p> <p>In this specific example, a better approach would be to break up your method calls (since you appear to be doing two things in one method: getting customer names and getting customer numbers) and instead have your results returned to the caller rather than passing in a collection...like this:</p> <pre><code>public ArrayList&lt;String&gt; getCustomerNames() throws java.rmi.RemoteException; public ArrayList&lt;String&gt; getCustomerNumbers() throws java.rmi.RemoteException; </code></pre> <p>Since both ArrayList and String implement Serializable, the results in the collection will be serialized and sent over the wire to the client code calling the method, at which point you can work with the data however you need. If instead you need to use a custom object in the collection, as long as your class implements the java.io.Serializable interface, and follows the specification for that interface you should have no problems.</p> <p>This would result in two separate calls over the wire, but is a much cleaner and simpler interaction, and avoids the reference breaking problem in your original example.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload