diff --git a/src/google/protobuf/compiler/java/lite/message.cc b/src/google/protobuf/compiler/java/lite/message.cc index 79c3c3e642ed7..7b8a1284c81ce 100644 --- a/src/google/protobuf/compiler/java/lite/message.cc +++ b/src/google/protobuf/compiler/java/lite/message.cc @@ -357,7 +357,6 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { printer->Print( "}\n" - "// fall through\n" "case GET_DEFAULT_INSTANCE: {\n" " return DEFAULT_INSTANCE;\n" "}\n" @@ -384,8 +383,6 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { " return parser;\n", "classname", name_resolver_->GetImmutableClassName(descriptor_)); - printer->Outdent(); - if (HasRequiredFields(descriptor_)) { printer->Print( "}\n" @@ -409,11 +406,13 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) { printer->Outdent(); printer->Print( - " }\n" - " throw new UnsupportedOperationException();\n" "}\n" - "\n", - "classname", name_resolver_->GetImmutableClassName(descriptor_)); + "// Should never happen. Generates tight code to throw an exception.\n" + "throw null;\n"); + printer->Outdent(); + printer->Print( + "}\n" + "\n"); printer->Print( "\n" diff --git a/src/google/protobuf/message_lite.h b/src/google/protobuf/message_lite.h index 58c5c2bdddd07..bbd9dc9b386d0 100644 --- a/src/google/protobuf/message_lite.h +++ b/src/google/protobuf/message_lite.h @@ -77,6 +77,10 @@ class MessageTableTester; namespace internal { +namespace v2 { +class TableDriven; +} // namespace v2 + class MessageCreator { public: using Func = void* (*)(const void*, void*, Arena*); @@ -987,6 +991,7 @@ class PROTOBUF_EXPORT MessageLite { friend class internal::WeakFieldMap; friend class internal::WireFormatLite; friend class internal::RustMapHelper; + friend class internal::v2::TableDriven; friend internal::MessageCreator; template