Skip to content

Commit

Permalink
Remove synthetic oneofs from Java gencode field accessor tables.
Browse files Browse the repository at this point in the history
This is needed to unblock Java editions codegen tests, due to codegen diff for proto3 optionals migrated to editions.

This is incompatible with runtimes <24.x, but our cross-version support policy explicitly does not guarantee compatibility for new gencode with old runtimes: https://protobuf.dev/support/cross-version-runtime-guarantee/#minor

PiperOrigin-RevId: 572578693
  • Loading branch information
zhangskz authored and Copybara-Service committed Oct 11, 2023
1 parent f0392ec commit 9ad2268
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/google/protobuf/compiler/java/message.cc
Expand Up @@ -224,10 +224,9 @@ int ImmutableMessageGenerator::GenerateFieldAccessorTableInitializer(
bytecode_estimate += 6;
printer->Print("\"$field_name$\", ", "field_name", info->capitalized_name);
}
// TODO: Once cl/534906231 propagates, only consider real oneofs
// since proto reflection does not use this for synthetic oneofs.
for (int i = 0; i < descriptor_->oneof_decl_count(); i++) {
const OneofDescriptor* oneof = descriptor_->oneof_decl(i);

for (int i = 0; i < descriptor_->real_oneof_decl_count(); i++) {
const OneofDescriptor* oneof = descriptor_->real_oneof_decl(i);
const OneofGeneratorInfo* info = context_->GetOneofGeneratorInfo(oneof);
bytecode_estimate += 6;
printer->Print("\"$oneof_name$\", ", "oneof_name", info->capitalized_name);
Expand Down

0 comments on commit 9ad2268

Please sign in to comment.