Right, Descriptor.toProto() returns a DescriptorProto, which is itself a
protobuf type. So, calling newBuilderForType() on that is going to return a
builder for DescriptorProto, not a builder for the type described.
What you want is com.google.protobuf.DynamicMessage.
Note that DynamicMessage is slower than the message classes produced by
protoc. So if the type in question is actually compiled in to your app, you
should use it instead. Typically what you'd do is pass around the type's
default instance (MyMessageType.getDefaultInstance()) instead of passing
around the descriptor.
Note that the Service interface also provides a method
getRequestPrototype(MethodDescriptor) which returns the default instance for
the type, on which you can then call newBuilderForType().
On Sat, Feb 20, 2010 at 12:54 PM, ph <pkirsa...@gmail.com> wrote:
> I'm trying to build service return message using
> This does not work:
> ( methodName ).getOutputType.toProto.newBuilderForType.mergeFrom
> ( msg ).build
> "msg" is byte array
> It builds DesscriptorProtos.DescriptorProto instead of Message.
> Is there a way to build message from byte array using method
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To post to this group, send email to proto...@googlegroups.com.
> To unsubscribe from this group, send email to
> For more options, visit this group at
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to proto...@googlegroups.com.
To unsubscribe from this group, send email to
For more options, visit this group at