Make the PARSER @Deprecated public.

(cherry-picking an intenral change).
pull/735/head
Feng Xiao 9 years ago
parent f4ef8fe3b8
commit cc5a1bfede
  1. 6
      src/google/protobuf/compiler/java/java_helpers.h
  2. 7
      src/google/protobuf/compiler/java/java_message.cc

@ -310,6 +310,12 @@ inline bool SupportFieldPresence(const FileDescriptor* descriptor) {
return descriptor->syntax() != FileDescriptor::SYNTAX_PROTO3;
}
// Whether generate classes expose public PARSER instances.
inline bool ExposePublicParser(const FileDescriptor* descriptor) {
// TODO(liujisi): Mark the PARSER private in 3.1.x releases.
return descriptor->syntax() == FileDescriptor::SYNTAX_PROTO2;
}
// Whether unknown enum values are kept (i.e., not stored in UnknownFieldSet
// but in the message and can be queried using additional getters that return
// ints.

@ -1248,8 +1248,11 @@ GenerateParsingConstructor(io::Printer* printer) {
// ===================================================================
void ImmutableMessageGenerator::GenerateParser(io::Printer* printer) {
printer->Print(
"private static final com.google.protobuf.Parser<$classname$> PARSER =\n"
" new com.google.protobuf.AbstractParser<$classname$>() {\n",
"$visibility$ static final com.google.protobuf.Parser<$classname$>\n"
" PARSER = new com.google.protobuf.AbstractParser<$classname$>() {\n",
"visibility",
ExposePublicParser(descriptor_->file()) ? "@java.lang.Deprecated public"
: "private",
"classname", descriptor_->name());
printer->Indent();
printer->Print(

Loading…
Cancel
Save