seasonouc / protostuff

Automatically exported from code.google.com/p/protostuff
Apache License 2.0
0 stars 0 forks source link

Incompatible with Protobuf 2.4.1 because of hasXXX() #84

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Compile a .proto file with protoc version 2.4.1
2. Try to generate JSON using Protostuff

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

Protostuff prints errors such as this one:

     [java] java.lang.RuntimeException: java.lang.NoSuchFieldException: hasDialogTitle
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:194)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:771)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:221)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:108)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
     [java]     at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:390)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:411)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
     [java]     at org.apache.tools.ant.Main.runBuild(Main.java:809)
     [java]     at org.apache.tools.ant.Main.startAnt(Main.java:217)
     [java]     at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
     [java]     at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
     [java] Caused by: java.lang.RuntimeException: java.lang.NoSuchFieldException: hasDialogTitle
     [java]     at com.dyuproject.protostuff.model.MessagePropertyAccessor$FieldAccess.init(MessagePropertyAccessor.java
:110)
     [java]     at com.dyuproject.protostuff.model.MessagePropertyAccessor.<init>(MessagePropertyAccessor.java:44)
     [java]     at com.dyuproject.protostuff.model.DefaultProperty.<init>(DefaultProperty.java:48)
     [java]     at com.dyuproject.protostuff.model.DefaultProperty$1.create(DefaultProperty.java:34)
     [java]     at com.dyuproject.protostuff.model.DefaultProperty$1.create(DefaultProperty.java:31)
     [java]     at com.dyuproject.protostuff.model.Model.<init>(Model.java:59)
     [java]     at com.dyuproject.protostuff.model.Model.get(Model.java:35)
     [java]     at com.dyuproject.protostuff.codegen.CodeGenerator.appendModel(CodeGenerator.java:53)
     [java]     at com.dyuproject.protostuff.codegen.CodeGenerator.generateFrom(CodeGenerator.java:100)
     [java]     at com.dyuproject.protostuff.codegen.GeneratorMain.generateFrom(GeneratorMain.java:201)
     [java]     at com.dyuproject.protostuff.codegen.GeneratorMain.generateFrom(GeneratorMain.java:219)
     [java]     at com.dyuproject.protostuff.codegen.GeneratorMain.main(GeneratorMain.java:272)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.run(ExecuteJava.java:217)
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:152)
     [java]     ... 20 more
     [java] Caused by: java.lang.NoSuchFieldException: hasDialogTitle
     [java]     at java.lang.Class.getDeclaredField(Class.java:1882)
     [java]     at com.dyuproject.protostuff.model.MessagePropertyAccessor$FieldAccess.init(MessagePropertyAccessor.java
:99)
     [java]     ... 37 more
     [java] Java Result: -1

The reason is that the implementation of 'hasXXX' changed. In Protobuf 2.3.0 
there were private fields that contained this value. E.g.:

    private boolean hasDialogTitle;
    public boolean hasDialogTitle() { return hasDialogTitle; }

But in protobuf 2.4.1 there is no longer a separate field; there's only a 
shared bit-field, which the hasXXX() method checks:

    public boolean hasDialogTitle() {
      return ((bitField0_ & 0x00000010) == 0x00000010);
    }

Original issue reported on code.google.com by or...@kitely.com on 17 Oct 2011 at 12:18

GoogleCodeExporter commented 8 years ago
That module (and its related modules) is no longer maintained as it has severe 
limitaitons when introspecting/generating from protos.  
Let me know if somebody wants to maintain this module.

Original comment by david.yu...@gmail.com on 22 Oct 2011 at 7:09

GoogleCodeExporter commented 8 years ago
Hello, I'm new to protostuff and I'm trying to use it to generate  json based 
on already existing protobuf messages. 
I don't know if this bug report refers to java_v2protoc_schema 
http://code.google.com/p/protostuff/wiki/JsonSerialization, I hope not. In any 
case please make it clear what exactly this refers to so that people that are 
new to the project don't get confused.
thanks

Original comment by xproma...@gmail.com on 30 Apr 2012 at 9:59

GoogleCodeExporter commented 8 years ago
Nope this is not related to java_v2protoc_schema.
I should probably remove this module as it has been superceded by 
java_v2protoc_schema.

Original comment by david.yu...@gmail.com on 30 Apr 2012 at 2:14