How to pass Class[] and Object[] to gwt service?
I'm trying to pass arguments of type Class[] and Object[] to a service which implements reflection to find the invoke the required method On the server.Here is the method sig开发者_JAVA百科nature
public void invokeMethod(String methodName,Class [] params,Objects [] args){
................
}
I have read that Object and Class aren't serializable in Gwt, So is there any workaround for this?
Thanks
Not really. The GWT compiler needs to know every class you're going to serialise so that it can generate appropriate stubs, etc. for you. If the number of things you're going to pass inside the Object[]
is limited, then you can hack around this by adding a method to your interface like this:
public void hackSoGWTCompilerKnowsAllTypes(MyFirstClass unused1, MySecondClass unused2 /* ... */);
When the GWT compiler encounters this, it will generate the appropriate marshalling code for MyFirstClass, MySecondClass, etc., but it is an ugly hack.
精彩评论