Closed GoogleCodeExporter closed 9 years ago
This is working as intended. bitFields should be initialized to all zeros and
it's reasonable to not do it again in the init method when JVM already does
that.
The init method is a private method. If you intend to call it by yourself (or
set data members directly), you are probably doing it wrong.
Original comment by xiaof...@google.com
on 15 Apr 2014 at 8:49
[deleted comment]
Ok, I needed different behavior from the parsing so I had to call it by myself
and I noticed this handling of bitFields and since I was not sure if it was
intended or not rather brought it up. Thank you for such a quick answer.
Original comment by kral.voj...@gmail.com
on 15 Apr 2014 at 9:00
If you are implementing your own parsing methods, it's better to only use
public methods (e.g., clear() when you want to reset a mesasge). Internal
methods may change without notice so depending on them is not a very good idea.
Original comment by xiaof...@google.com
on 15 Apr 2014 at 9:13
And just quick wondering why are the other number types properties not set as
bitFields so by JVM only without the setting in initialization method?
Original comment by kral.voj...@gmail.com
on 15 Apr 2014 at 9:13
Re #5:
JVM will only set the value to 0 but an integral protobuf field may have a
non-zero default value (set by field option [default = 12345]). When generating
the init method it's easier to just generate an assignment statement for every
field no matter whether the default value is 0 or not. This is an
implementation detail though. We could change it to not initialize integral
fields whose default value is 0.
Original comment by xiaof...@google.com
on 15 Apr 2014 at 9:21
I see. That is what confuse me the difference between attributes with zeros and
the bitFields.
Original comment by kral.voj...@gmail.com
on 15 Apr 2014 at 9:51
Original issue reported on code.google.com by
kral.voj...@gmail.com
on 15 Apr 2014 at 7:47