diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2014-11-20 16:18:53 -0800 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2014-11-20 16:18:53 -0800 |
commit | 99aa0f9e8f1a88def7bdebf1385678559cda0707 (patch) | |
tree | 7ccb663ee9a1c722bf6062435ac705e83568c7e8 /java/src/main | |
parent | 49bc8c09636ae61f9c685d121278c3738b9a809a (diff) | |
download | protobuf-99aa0f9e8f1a88def7bdebf1385678559cda0707.tar.gz protobuf-99aa0f9e8f1a88def7bdebf1385678559cda0707.tar.bz2 protobuf-99aa0f9e8f1a88def7bdebf1385678559cda0707.zip |
Down-integrate from internal code base.
Diffstat (limited to 'java/src/main')
-rw-r--r-- | java/src/main/java/com/google/protobuf/GeneratedMessageLite.java | 31 | ||||
-rw-r--r-- | java/src/main/java/com/google/protobuf/Internal.java | 4 |
2 files changed, 13 insertions, 22 deletions
diff --git a/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java index 06492cc9..4d25c077 100644 --- a/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -55,14 +55,6 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite /** For use by generated code only. */ protected UnknownFieldSetLite unknownFields; - protected GeneratedMessageLite() { - unknownFields = UnknownFieldSetLite.getDefaultInstance(); - } - - protected GeneratedMessageLite(Builder builder) { - unknownFields = builder.unknownFields; - } - public Parser<? extends MessageLite> getParserForType() { throw new UnsupportedOperationException( "This is supposed to be overridden by subclasses."); @@ -87,7 +79,9 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite extends AbstractMessageLite.Builder<BuilderType> { private final MessageType defaultInstance; - private UnknownFieldSetLite unknownFields = + + /** For use by generated code only. */ + protected UnknownFieldSetLite unknownFields = UnknownFieldSetLite.getDefaultInstance(); protected Builder(MessageType defaultInstance) { @@ -211,16 +205,8 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite * Represents the set of extensions on this message. For use by generated * code only. */ - protected final FieldSet<ExtensionDescriptor> extensions; - - protected ExtendableMessage() { - this.extensions = FieldSet.newFieldSet(); - } - - protected ExtendableMessage(ExtendableBuilder<MessageType, ?> builder) { - this.extensions = builder.buildExtensions(); - } - + protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet(); + private void verifyExtensionContainingType( final GeneratedExtension<MessageType, ?> extension) { if (extension.getContainingTypeDefaultInstance() != @@ -396,8 +382,10 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite /** * Called by the build code path to create a copy of the extensions for * building the message. + * <p> + * For use by generated code only. */ - private FieldSet<ExtensionDescriptor> buildExtensions() { + protected final FieldSet<ExtensionDescriptor> buildExtensions() { extensions.makeImmutable(); extensionsIsMutable = false; return extensions; @@ -472,8 +460,7 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite // of this dummy clone() implementation makes it go away. @Override public BuilderType clone() { - throw new UnsupportedOperationException( - "This is supposed to be overridden by subclasses."); + return super.clone(); } /** Set the value of an extension. */ diff --git a/java/src/main/java/com/google/protobuf/Internal.java b/java/src/main/java/com/google/protobuf/Internal.java index ba0f526b..5ef39418 100644 --- a/java/src/main/java/com/google/protobuf/Internal.java +++ b/java/src/main/java/com/google/protobuf/Internal.java @@ -393,6 +393,10 @@ public class Internal { */ public static final ByteBuffer EMPTY_BYTE_BUFFER = ByteBuffer.wrap(EMPTY_BYTE_ARRAY); + + /** An empty coded input stream constant used in generated code. */ + public static final CodedInputStream EMPTY_CODED_INPUT_STREAM = + CodedInputStream.newInstance(EMPTY_BYTE_ARRAY); /** |