Q:

Is it possible to pass an anonymous object as argument of an RMI method?

I am trying to invoke a remote method via RMI that takes 1 argument of type MyData, which is an interface known in both server side and client side.
In my client class MyClass, I created an anonymous object of type MyData, and passed it to the remote method, and got an exception:
Caused by: java.lang.reflect.InvocationTargetException
    at wt.method.RemoteMethodServer.invoke(RemoteMethodServer.java:795)
    at 
    ... 2 more
Caused by: java.lang.ClassNotFoundException: MyClass$1 (no security manager: RMI class loader disabled)

Question: Must I use an implementation of the interface MyData to pass RMI method argument? That implementation is known on both server and client sides.

A:

It's possible if:

The class is deployed to the CLASSPATH of the peer, or available via the codebase feature, and
The class within which it is defined is Serializable, and
You realize and accept that the outer class instance will be sent along with the anonymous class, because it's an inner class and has a reference to its outer class, and therefore that the outer class also has to be deployed to the peer or available via the codebase feature.

(2) May not be true, and may not need to be true for any reason other than this, and (3) is very likely to be untrue, as it is very likely to be a client-only class that is none of the server's business.
Don't do this. There is no advantage, and several disadvantages. Use an outer or static class.

