1 Reply Latest reply on Feb 14, 2012 3:30 PM by Christian Sadilek

    Cannot send static inner class from server to client

    fvitorc Newbie



      I was trying to send a static inner class from server to client, but I started to get some weird exceptions on the client side.

      Gladly I found the source of this bug. Let me show an example:


      Let's supose we have the following classes:


      package pckg;

      public class Foo {

           public static class Bar {}



      When I try to send an instance of Foo.Bar to the client, the JSON enconder outputs something like this:



      That's what is causing the client to get nuts. It should be pckg.Foo$Bar instead of pckg.Foo.Bar

      To fix this, just change every reference from Class.getCanonicalName() to Class.getName() in the class JSONEncoder.



      BTW, I was getting the following exception on the client when trying to get a message part:

      com.google.gwt.core.client.JavaScriptException: (TypeError): Cannot call method 'get' of null


      And the message part I was trying to access was not even the inner class that had the problem.

      There might be some problem with the decoding on the client, because it is not validating the incoming message.


      PS.: All those things I am reporting here are from version 1.3.2.Final