Hi gurpreet,
Yes, technically, Java uses pass by value semantics. However, what it passes is - the reference. That is, while invoking method processList, a copy is made of 'reference to inList', and it is passed to processList.
Also, Ivan's notes put it correctly. Now, since we pass a copy of the reference, the moment you change that copy of a reference (to refer to some another list), it is lost, and this new list won't be available to be accessed from outside the method.
Basically, what the spec (and Ivan's notes) say is:
1) When local view of an
EJB is used, then copy of the reference is made (thus, both references refer to same 'inList'). And hence, if a change is done to inList inside the method, it will be also visible outside the method. This is possible only because it is a local call, and thus we are not crossing JVM boundries.
2) When remote view of an EJB is used, then the whole inList is serialized, sent from one JVM to another JVM(which may or may not be on same physical machine). Thus, in new JVM, inList has new reference, and now we have two references to two different inList (which belongs to two different JVMs). Thus, change made by a reference in one JVM (e.g. via processList method) is not visible in another JVM (unless the list is explicitly returned, but here, processList returns void). You can try the same piece of code with remote view and you won't find 'String added in EJB' in the list - because it was added in another JVM, and the reference was not returned to original JVM.
I hope this helps.