On Tue, Jul 24, 2012 at 3:55 PM, Tobias Neef <[email protected]> wrote:

> I try to convert the Java representation of a protobuf message into another
> message with the same fields (ordering, names, types). I try to do it the
> following way but this ends in a java.lang.InstantiationException:
>
> public static <T extends GeneratedMessage> T commandToEvent(GeneratedMessage
> command,
> Class<T> clazz) {
> try {
> Builder builder = clazz.newInstance().newBuilderForType();

Generated message classes don't have a public ctor, so newInstance() will fail.
Pass the default instance of the message class, not the class itself,
to identify the message type to build?

Oliver

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/protobuf?hl=en.

Reply via email to