You need to use the field descriptor for the field you want to look at. You can get ahold of the field descriptor by using "findFieldByName" or "findFieldByNumber" FieldDescriptor myFieldDescriptor = MyProtoFileClass.MyMessage.getDescriptor().findFieldByNumber(MyProtoFileClass.MyMessage.MYFIELD_FIELD_NUMBER);
(anybody know a better way to get field descriptors?) Object myExtensionValue = myFieldDescriptor.getOptions().getField(MyProtoFileClass.myfieldoption.getDescriptor()); On Mar 4, 8:49 am, Harpreet <hpreet.si...@gmail.com> wrote: > Hi, > > I was scanning the Language Guide and saw that there are simple ways > to access the MessageOptions defined in the java code like: > > String value = > MyProtoFile.MyMessage.getDescriptor().getOptions().getExtension(MyProtoFile.myOption); > > However if i have a field option like (using the e.g. in Language > guide) > extend google.protobuf.FieldOptions { > optional float my_field_option = 50002; > > } > > optional int32 foo = 1 [(my_field_option) = 4.5]; > > How do I access the my_field_option value in Java. The > MyProtoFile.myFieldOption static member does exist, but I don't know > how to use it. > > I have tried a lot of things, but was unable to figure out a way. > > Thanks, Harpreet -- You received this message because you are subscribed to the Google Groups "Protocol Buffers" group. To post to this group, send email to protobuf@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.