I’m having trouble accessing extended protocol buffer members. Here is the scenario:
Message Foo { optional int i = 1; }
message Bar { extend Foo {
optional int j = 10001; } }
I don’t have the Bar message within any of my other protos. How can I get Bar.j in Java? All examples I’ve found require a Bar within a message.
Thanks!
Extensions in Protocol Buffer don’t work necessarily as you would expect, i.e. they don’t match the Java inheritance mechanism.
For your problem, I have created the following
foobar.protofile:It creates
Foobar.java, containing the classesFoobar.BarandFoobar.Foo.And here is a simple JUnit test case accessing Bar.j:
Hope that helps clarifying your problem!