You need to use the field descriptor for the field you want to look

You can get ahold of the field descriptor by using "findFieldByName"
or "findFieldByNumber"
FieldDescriptor myFieldDescriptor =

(anybody know a better way to get field descriptors?)

Object myExtensionValue =

On Mar 4, 8:49 am, Harpreet <> 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
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to