diff --git a/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java b/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java index 2c839aa659..b48c304c7d 100644 --- a/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java +++ b/java/core/src/main/java/com/google/protobuf/NewInstanceSchemaFull.java @@ -10,7 +10,6 @@ package com.google.protobuf; final class NewInstanceSchemaFull implements NewInstanceSchema { @Override public Object newInstance(Object defaultInstance) { - return ((GeneratedMessage) defaultInstance) - .newInstance(GeneratedMessage.UnusedPrivateParameter.INSTANCE); + return ((Message) defaultInstance).toBuilder().buildPartial(); } } diff --git a/src/google/protobuf/compiler/java/message.cc b/src/google/protobuf/compiler/java/message.cc index 57003839ca..01ec4a6063 100644 --- a/src/google/protobuf/compiler/java/message.cc +++ b/src/google/protobuf/compiler/java/message.cc @@ -357,15 +357,6 @@ void ImmutableMessageGenerator::Generate(io::Printer* printer) { "}\n" "\n"); - printer->Print(variables, - "@java.lang.Override\n" - "@SuppressWarnings({\"unused\"})\n" - "protected java.lang.Object newInstance(\n" - " UnusedPrivateParameter unused) {\n" - " return new $classname$();\n" - "}\n" - "\n"); - GenerateDescriptorMethods(printer); // Nested types