Status: New
Owner: [email protected]
Labels: Type-Defect Priority-Medium
New issue 266 by [email protected]: Protoc generates unused variable in
Java for protobuf with single repeated field
http://code.google.com/p/protobuf/issues/detail?id=266
What steps will reproduce the problem?
1. Create a protobuf definition for a message with a single repeated field
of any type
2. Run protoc on it to generate Java classes
What is the expected output? What do you see instead?
The resulting .java source file defines a variable ("int from_bitField0_")
in the message builder's buildPartial method that is never read and thus
causes a compiler warning.
What version of the product are you using? On what operating system?
2.4.0a, on Mac OS X 10.6.6
Please provide any additional information below.
I believe the issue arises because the Repeatable*Field classes in the Java
code generator include the mutability bit in the count of required "builder
bits" for which "local" bit field variables are created, but the
GenerateBuildingCode() method doesn't use it. So if there's only a single
field in a message, and it's repeatable, a local bit field gets created but
never used.
I've attached a patch that modifies GenerateBuildingCode() in the three
field type handler classes to generate code that reads the local bit field.
Attachments:
use_local_bit_builder_for_mutability.diff 3.3 KB
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.