diff options
author | Jisi Liu <jisi.liu@gmail.com> | 2015-08-25 17:03:49 -0700 |
---|---|---|
committer | Jisi Liu <jisi.liu@gmail.com> | 2015-08-25 17:03:49 -0700 |
commit | 144ea006599ca7858c3aaecbcc2f06f451271830 (patch) | |
tree | e08f0368f7df173baa0a811d690145a5f394dc96 /src | |
parent | 4c663d810e238b1ada06bb8eeaa648db9bb7f8c7 (diff) | |
parent | cc5a1bfede7f5b691760ae3efe271961e466cedb (diff) |
Merge branch 'beta-1' of github.com:google/protobuf into manual-merge
Diffstat (limited to 'src')
-rw-r--r-- | src/google/protobuf/compiler/java/java_helpers.h | 6 | ||||
-rw-r--r-- | src/google/protobuf/compiler/java/java_message.cc | 7 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/java/java_helpers.h b/src/google/protobuf/compiler/java/java_helpers.h index 7eef86a7..5392d6d7 100644 --- a/src/google/protobuf/compiler/java/java_helpers.h +++ b/src/google/protobuf/compiler/java/java_helpers.h @@ -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. diff --git a/src/google/protobuf/compiler/java/java_message.cc b/src/google/protobuf/compiler/java/java_message.cc index 80d6e9ad..19ba0707 100644 --- a/src/google/protobuf/compiler/java/java_message.cc +++ b/src/google/protobuf/compiler/java/java_message.cc @@ -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( |