Repository navigation
Conversation
oldergod
marked this pull request as ready for review
November 5, 2026 12:55
The new encodeInTagOrder option is for the Kotlin and Java targets. With it on, generated encode functions write fields in ascending tag order, so the bytes are the same as protoc. The default is false, and it does not change generated code. The Java generator fails when compact and encodeInTagOrder are both set. Closes #3746.
The last run of a split boxed oneof now writes every key that no earlier run writes. Before, a custom key with a tag in no run was not written, but encodedSize counted it. Runs also grow in place, so code generation time is linear in the oneof size.
The encode function no longer scans all segments for each split run.
oldergod
force-pushed
the
bquenaudon/encode-in-tag-order
branch
from
November 5, 2026 13:22
c0c4a5b to
e43ea8c
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds
encodeInTagOrderto thekotlin {}andjava {}targets.It is false by default.
With the option on, the generated
encodefunctions write fields in ascending tag order.The bytes are then the same as protoc.
This includes oneof fields and extension fields.
In Kotlin, a boxed or sealed oneof splits around plain fields that have tags between its members.
With the option off, the generated code does not change.
The option applies only to the types that the target generates.
A nested type that another module or jar generates keeps its own field order.
You cannot use
compactandencodeInTagOrdertogether on ajava {}target, because compact code encodes by reflection.The Gradle plugin fails before code generation when both are set.
Closes #3746.
Release note:
encodeInTagOrderoption on thekotlin {}andjava {}targets. When it is true, the generatedencodefunctions write fields in ascending tag order, so the bytes are the same as protoc. It is false by default, and generated code does not change when it is false (Add an option to encode fields in tag order #3751)copyfunctions ofKotlinTargetandJavaTarget, the constructors ofKotlinSchemaHandlerandJavaSchemaHandler, andKotlinGenerator.invokehave a new last parameterencodeInTagOrderwith the default valuefalse. Kotlin source that calls them compiles without change. Java source that calls them must add the new argument. Code that is compiled against an earlier Wire version and calls them directly must be compiled again (Add an option to encode fields in tag order #3751)