Remove synthetic oneofs from Java gencode field accessor tables.

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
pull/14339/head
Sandy Zhang 1 year ago committed by Copybara-Service
parent f0392ecc42
commit 9ad2268544
  1. 7
      src/google/protobuf/compiler/java/message.cc

@ -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);

Loading…
Cancel
Save