Basically, you can't do that in pure Java - the compiler is a C++ binary, there is no Java version.
Still, working with the output of --descriptor_set_out is probably the way to go here. If you have the .proto file ahead of time, you can pregenerate the descriptor output at build time and store it instead of the .proto file. If you don't have the .proto file ahead of time (and you can't redesign - this is not a good design) then you could run the compiler at runtime and read the output. Either way, now you have a parsed version of the message format as a protobuf-encoded message that you can read into your Java program and extract the Descriptors you need. If you're looking at a selfdescribing message format, then I'd go with using the parsed descriptors as your format description, not the text .proto file. Oliver On 31 October 2014 17:56, Pradeep Gollakota <pradeep...@gmail.com> wrote: > Hi Oliver, > > Thanks for the response! I guess my question wasn't quite clear. In my java > code I have a string which contains the content of a .proto file. Given this > string, how can I create an instance of a Descriptor class so I can do > DynamicMessage parsing. > > Thanks! > - Pradeep > > On Thursday, October 30, 2014 2:41:19 PM UTC-7, Oliver wrote: >> >> On 30 October 2014 02:53, Pradeep Gollakota <prade...@gmail.com> wrote: >> >> > I have a use case where I need to parse messages without having the >> > corresponding precompiled classes in Java. So the DynamicMessage seems >> > to be >> > the correct fit, but I'm not sure how I can generate the DescriptorSet >> > from >> > the ".proto" definition. >> >> protoc --descriptor_set_out=FILE ? >> >> Oliver > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to protobuf+unsubscr...@googlegroups.com. > To post to this group, send email to protobuf@googlegroups.com. > Visit this group at http://groups.google.com/group/protobuf. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+unsubscr...@googlegroups.com. To post to this group, send email to protobuf@googlegroups.com. Visit this group at http://groups.google.com/group/protobuf. For more options, visit https://groups.google.com/d/optout.