Commit cc5a1bfe authored by Feng Xiao's avatar Feng Xiao

Make the PARSER @Deprecated public.

(cherry-picking an intenral change).
parent f4ef8fe3
......@@ -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(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment