fairyhawk / protostuff

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

Reflection compiler fails sometimes when using nested protobuf types #26

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If you have a protobuf file with nested messages:

message Parent {
  message Child {
    required string foo = 1;
  }

  required Child bar = 1;
}

... sometimes (depending on the java compiler's mood) the reflection code will 
fail with a NoSuchMethodException.

The bug is in LiteRuntime.class line 46:

      public ModelMeta create(Class<? extends AbstractMessageLite> messageClass)
        {
            Class<? extends Builder<?>> builderClass = 
                (Class<? extends Builder<?>>)messageClass.getDeclaredClasses()[0];

The code assumes Parent.Builder will be the first declared class in Parent. 
Sometimes it is, but sometimes Parent.Child will be the first declared class, 
and it crashes trying to call Parent.Child.getBar() instead of 
Parent.Builder.getBar().

Original issue reported on code.google.com by jose...@gmail.com on 1 Sep 2010 at 5:29

GoogleCodeExporter commented 8 years ago
See attached patch which fixes the issue.

Original comment by jose...@gmail.com on 1 Sep 2010 at 5:30

Attachments:

GoogleCodeExporter commented 8 years ago
fixed on rev 1008.
Thanks!

Original comment by david.yu...@gmail.com on 1 Sep 2010 at 8:09