google-code-export / rocket-gwt

Automatically exported from code.google.com/p/rocket-gwt
1 stars 1 forks source link

Json Serialization does not support more than 1 super class. #65

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

When you create a class hierarchy such as this:

public class SuperSuperClass
{
  public int ssc;
} 

public class SuperClass extends SuperSuperClass
{
 public int sc;
}

public class ChildClass extends SuperClass
{
  public int cc;
}

When ChildClass is serialized, you only get the values for sc and cc.  This
is because in the generated versions of writeJSon only contains calls for
this.writeFields and super.writeFields and stops there.  

This same problem occurs when deserializing as well.

What is the expected output? What do you see instead?

You should see serialized values for the entire super class hierarchy.  Not
just the immediate class and its super class.

What version of the product are you using? On what operating system?

0.56

Please provide any additional information below.

Original issue reported on code.google.com by jaredbr...@gmail.com on 17 Mar 2009 at 2:48

GoogleCodeExporter commented 9 years ago
I have a fix for this issue, but I'm not completely use if its the correct fix, 
so
submitting it to get feedback and for possible inclusion into the project.

To fix things, I changed the generation of writeJson to no longer call
super.writeFields.  Then I changed writefields-json.txt to include a call to
super.writeFields at the end.

To fix deserialization, I did sort of the same.  From the generation of 
readObject, I
removed the call to super.readFields.  Then I added a new template for a call to
super.readFields and I append it to the gernation ofr the super.readFields 
generation.

What I end up with is the following changed files:

rocket/json\rebind/JsonSerializerGenerator.java
rocket/json\rebind/writejson/write-json.txt
rocket/json\rebind/writefields/write-fields.txt
rocket/json\rebind/readcomplex/read-complex.txt

then added a new package rocket/json/rebind/readfields

I've attached a zip file with my changes.

Original comment by jaredbr...@gmail.com on 17 Mar 2009 at 3:59

Attachments:

GoogleCodeExporter commented 9 years ago
I too had this exact same problem. Here is my configuration.

Debian Linux Lenny testing.
Rocket 0.56
Google Web Toolkit 1.5.3
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)

public class EmbeddedJsonAction implements JsonSerializable, EmbeddedJsonObject 
{

public class Binding extends EmbeddedJsonAction implements JsonSerializable,
EmbeddedJsonObject {

public class FCBinding extends EmbeddedJsonAction implements JsonSerializable,
EmbeddedJsonObject

FCBinding sees all the declared fields in Binding but does not see any of the 
fields
in EmbeddedJsonAction. And if I serialize Binding it does see all of it's 
fields and
the fields in EmbeddedJsonAction.

I have not tried the patch that was applied as of yet.

Hope this helps and thank you for an extremely helpful tool.
-Chris

Original comment by chris.hi...@gmail.com on 1 Apr 2009 at 4:24