Commit 9cf65b7d authored by liujisi@google.com's avatar liujisi@google.com

Use fully qualified java.lang.Object in protoc java code.

parent eab9b5d4
...@@ -60,6 +60,10 @@ message Override { ...@@ -60,6 +60,10 @@ message Override {
optional int32 override = 1; optional int32 override = 1;
} }
message Object {
optional int32 object = 1;
}
service TestConflictingMethodNames { service TestConflictingMethodNames {
rpc Override(TestMessage) returns (TestMessage); rpc Override(TestMessage) returns (TestMessage);
} }
......
...@@ -550,7 +550,8 @@ GenerateMessageSerializationMethods(io::Printer* printer) { ...@@ -550,7 +550,8 @@ GenerateMessageSerializationMethods(io::Printer* printer) {
printer->Print( printer->Print(
"@java.lang.Override\n" "@java.lang.Override\n"
"protected Object writeReplace() throws java.io.ObjectStreamException {\n" "protected java.lang.Object writeReplace()\n"
" throws java.io.ObjectStreamException {\n"
" return super.writeReplace();\n" " return super.writeReplace();\n"
"}\n" "}\n"
"\n"); "\n");
...@@ -1182,7 +1183,7 @@ void MessageGenerator::GenerateIsInitialized( ...@@ -1182,7 +1183,7 @@ void MessageGenerator::GenerateIsInitialized(
void MessageGenerator::GenerateEqualsAndHashCode(io::Printer* printer) { void MessageGenerator::GenerateEqualsAndHashCode(io::Printer* printer) {
printer->Print( printer->Print(
"@java.lang.Override\n" "@java.lang.Override\n"
"public boolean equals(final Object obj) {\n"); "public boolean equals(final java.lang.Object obj) {\n");
printer->Indent(); printer->Indent();
printer->Print( printer->Print(
"if (obj == this) {\n" "if (obj == this) {\n"
......
...@@ -168,14 +168,14 @@ GenerateInterfaceMembers(io::Printer* printer) const { ...@@ -168,14 +168,14 @@ GenerateInterfaceMembers(io::Printer* printer) const {
void StringFieldGenerator:: void StringFieldGenerator::
GenerateMembers(io::Printer* printer) const { GenerateMembers(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"private Object $name$_;\n" "private java.lang.Object $name$_;\n"
"$deprecation$public boolean has$capitalized_name$() {\n" "$deprecation$public boolean has$capitalized_name$() {\n"
" return $get_has_field_bit_message$;\n" " return $get_has_field_bit_message$;\n"
"}\n"); "}\n");
printer->Print(variables_, printer->Print(variables_,
"$deprecation$public String get$capitalized_name$() {\n" "$deprecation$public String get$capitalized_name$() {\n"
" Object ref = $name$_;\n" " java.lang.Object ref = $name$_;\n"
" if (ref instanceof String) {\n" " if (ref instanceof String) {\n"
" return (String) ref;\n" " return (String) ref;\n"
" } else {\n" " } else {\n"
...@@ -189,7 +189,7 @@ GenerateMembers(io::Printer* printer) const { ...@@ -189,7 +189,7 @@ GenerateMembers(io::Printer* printer) const {
" }\n" " }\n"
"}\n" "}\n"
"private com.google.protobuf.ByteString get$capitalized_name$Bytes() {\n" "private com.google.protobuf.ByteString get$capitalized_name$Bytes() {\n"
" Object ref = $name$_;\n" " java.lang.Object ref = $name$_;\n"
" if (ref instanceof String) {\n" " if (ref instanceof String) {\n"
" com.google.protobuf.ByteString b = \n" " com.google.protobuf.ByteString b = \n"
" com.google.protobuf.ByteString.copyFromUtf8((String) ref);\n" " com.google.protobuf.ByteString.copyFromUtf8((String) ref);\n"
...@@ -204,14 +204,14 @@ GenerateMembers(io::Printer* printer) const { ...@@ -204,14 +204,14 @@ GenerateMembers(io::Printer* printer) const {
void StringFieldGenerator:: void StringFieldGenerator::
GenerateBuilderMembers(io::Printer* printer) const { GenerateBuilderMembers(io::Printer* printer) const {
printer->Print(variables_, printer->Print(variables_,
"private Object $name$_ $default_init$;\n" "private java.lang.Object $name$_ $default_init$;\n"
"$deprecation$public boolean has$capitalized_name$() {\n" "$deprecation$public boolean has$capitalized_name$() {\n"
" return $get_has_field_bit_builder$;\n" " return $get_has_field_bit_builder$;\n"
"}\n"); "}\n");
printer->Print(variables_, printer->Print(variables_,
"$deprecation$public String get$capitalized_name$() {\n" "$deprecation$public String get$capitalized_name$() {\n"
" Object ref = $name$_;\n" " java.lang.Object ref = $name$_;\n"
" if (!(ref instanceof String)) {\n" " if (!(ref instanceof String)) {\n"
" String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();\n" " String s = ((com.google.protobuf.ByteString) ref).toStringUtf8();\n"
" $name$_ = s;\n" " $name$_ = s;\n"
......
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