diff --git a/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageInternal.java b/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageInternal.java new file mode 100644 index 0000000..3e9d6be --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageInternal.java @@ -0,0 +1,554 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf; + +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.OneofDescriptor; +import com.google.protobuf.Internal.EnumLite; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * A partial implementation of the {@link Message} interface which implements as many methods of + * that interface as possible in terms of other methods. + * + * @author kenton@google.com Kenton Varda + */ +abstract class AbstractMessageInternal + // TODO: Update GeneratedMessage to parameterize with MessageType and BuilderType. + extends AbstractMessageLite implements Message { + + @Override + public boolean isInitialized() { + return MessageReflection.isInitialized(this); + } + + /** + * Interface for the parent of a Builder that allows the builder to communicate invalidations back + * to the parent for use when using nested builders. + */ + protected interface BuilderParent extends Message.BuilderParent{ + + /** + * A builder becomes dirty whenever a field is modified -- including fields in nested builders + * -- and becomes clean when build() is called. Thus, when a builder becomes dirty, all its + * parents become dirty as well, and when it becomes clean, all its children become clean. The + * dirtiness state is used to invalidate certain cached values. + * + *

To this end, a builder calls markDirty() on its parent whenever it transitions from clean + * to dirty. The parent must propagate this call to its own parent, unless it was already dirty, + * in which case the grandparent must necessarily already be dirty as well. The parent can only + * transition back to "clean" after calling build() on all children. + */ + void markDirty(); + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public boolean hasOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + @Override + public final String toString() { + return TextFormatInternal.printer().printToString(this); + } + + @Override + public void writeTo(final CodedOutputStream output) throws IOException { + MessageReflection.writeMessageTo(this, getAllFields(), output, false); + } + + protected int memoizedSize = -1; + + @Override + int getMemoizedSerializedSize() { + return memoizedSize; + } + + @Override + void setMemoizedSerializedSize(int size) { + memoizedSize = size; + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) { + return size; + } + + memoizedSize = MessageReflection.getSerializedSize(this, getAllFields()); + return memoizedSize; + } + + @Override + public boolean equals(final Object other) { + if (other == this) { + return true; + } + if (!(other instanceof Message)) { + return false; + } + final Message otherMessage = (Message) other; + if (getDescriptorForType() != otherMessage.getDescriptorForType()) { + return false; + } + return compareFields(getAllFields(), otherMessage.getAllFields()) + && getUnknownFields().equals(otherMessage.getUnknownFields()); + } + + @Override + public int hashCode() { + int hash = memoizedHashCode; + if (hash == 0) { + hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = hashFields(hash, getAllFields()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + } + return hash; + } + + private static ByteString toByteString(Object value) { + if (value instanceof byte[]) { + return ByteString.copyFrom((byte[]) value); + } else { + return (ByteString) value; + } + } + + /** + * Compares two bytes fields. The parameters must be either a byte array or a ByteString object. + * They can be of different type though. + */ + private static boolean compareBytes(Object a, Object b) { + if (a instanceof byte[] && b instanceof byte[]) { + return Arrays.equals((byte[]) a, (byte[]) b); + } + return toByteString(a).equals(toByteString(b)); + } + + /** Converts a list of MapEntry messages into a Map used for equals() and hashCode(). */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static Map convertMapEntryListToMap(List list) { + if (list.isEmpty()) { + return Collections.emptyMap(); + } + Map result = new HashMap<>(); + Iterator iterator = list.iterator(); + Message entry = (Message) iterator.next(); + Descriptors.Descriptor descriptor = entry.getDescriptorForType(); + FieldDescriptor key = descriptor.findFieldByName("key"); + FieldDescriptor value = descriptor.findFieldByName("value"); + Object fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + while (iterator.hasNext()) { + entry = (Message) iterator.next(); + fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + } + return result; + } + + /** Compares two map fields. The parameters must be a list of MapEntry messages. */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static boolean compareMapField(Object a, Object b) { + Map ma = convertMapEntryListToMap((List) a); + Map mb = convertMapEntryListToMap((List) b); + return MapFieldLite.equals(ma, mb); + } + + /** + * Compares two sets of fields. This method is used to implement {@link + * AbstractMessageInternal#equals(Object)} and {@link AbstractMutableMessage#equals(Object)}. It takes + * special care of bytes fields because immutable messages and mutable messages use different Java + * type to represent a bytes field and this method should be able to compare immutable messages, + * mutable messages and also an immutable message to a mutable message. + */ + static boolean compareFields(Map a, Map b) { + if (a.size() != b.size()) { + return false; + } + for (FieldDescriptor descriptor : a.keySet()) { + if (!b.containsKey(descriptor)) { + return false; + } + Object value1 = a.get(descriptor); + Object value2 = b.get(descriptor); + if (descriptor.getType() == FieldDescriptor.Type.BYTES) { + if (descriptor.isRepeated()) { + List list1 = (List) value1; + List list2 = (List) value2; + if (list1.size() != list2.size()) { + return false; + } + for (int i = 0; i < list1.size(); i++) { + if (!compareBytes(list1.get(i), list2.get(i))) { + return false; + } + } + } else { + // Compares a singular bytes field. + if (!compareBytes(value1, value2)) { + return false; + } + } + } else if (descriptor.isMapField()) { + if (!compareMapField(value1, value2)) { + return false; + } + } else { + // Compare non-bytes fields. + if (!value1.equals(value2)) { + return false; + } + } + } + return true; + } + + /** Calculates the hash code of a map field. {@code value} must be a list of MapEntry messages. */ + @SuppressWarnings("unchecked") + private static int hashMapField(Object value) { + return MapFieldLite.calculateHashCodeForMap(convertMapEntryListToMap((List) value)); + } + + /** Get a hash code for given fields and values, using the given seed. */ + @SuppressWarnings("unchecked") + protected static int hashFields(int hash, Map map) { + for (Map.Entry entry : map.entrySet()) { + FieldDescriptor field = entry.getKey(); + Object value = entry.getValue(); + hash = (37 * hash) + field.getNumber(); + if (field.isMapField()) { + hash = (53 * hash) + hashMapField(value); + } else if (field.getType() != FieldDescriptor.Type.ENUM) { + hash = (53 * hash) + value.hashCode(); + } else if (field.isRepeated()) { + List list = (List) value; + hash = (53 * hash) + Internal.hashEnumList(list); + } else { + hash = (53 * hash) + Internal.hashEnum((EnumLite) value); + } + } + return hash; + } + + /** + * Package private helper method for AbstractParser to create UninitializedMessageException with + * missing field information. + */ + @Override + UninitializedMessageException newUninitializedMessageException() { + return Builder.newUninitializedMessageException(this); + } + + // ================================================================= + + /** + * A partial implementation of the {@link Message.Builder} interface which implements as many + * methods of that interface as possible in terms of other methods. + */ + @SuppressWarnings("unchecked") + public abstract static class Builder> + extends AbstractMessageLite.Builder implements Message.Builder { + // The compiler produces an error if this is not declared explicitly. + // Method isn't abstract to bypass Java 1.6 compiler issue: + // http://bugs.java.com/view_bug.do?bug_id=6908259 + @Override + public BuilderType clone() { + throw new UnsupportedOperationException("clone() should be implemented in subclasses."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public boolean hasOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public BuilderType clearOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("clearOneof() is not implemented."); + } + + @Override + public BuilderType clear() { + for (final Map.Entry entry : getAllFields().entrySet()) { + clearField(entry.getKey()); + } + return (BuilderType) this; + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + @Override + protected BuilderType internalMergeFrom(AbstractMessageLite other) { + return mergeFrom((Message) other); + } + + @Override + public BuilderType mergeFrom(final Message other) { + return mergeFrom(other, other.getAllFields()); + } + + BuilderType mergeFrom(final Message other, Map allFields) { + if (other.getDescriptorForType() != getDescriptorForType()) { + throw new IllegalArgumentException( + "mergeFrom(Message) can only merge messages of the same type."); + } + + // Note: We don't attempt to verify that other's fields have valid + // types. Doing so would be a losing battle. We'd have to verify + // all sub-messages as well, and we'd have to make copies of all of + // them to insure that they don't change after verification (since + // the Message interface itself cannot enforce immutability of + // implementations). + + for (final Map.Entry entry : allFields.entrySet()) { + final FieldDescriptor field = entry.getKey(); + if (field.isRepeated()) { + for (final Object element : (List) entry.getValue()) { + addRepeatedField(field, element); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + final Message existingValue = (Message) getField(field); + if (existingValue == existingValue.getDefaultInstanceForType()) { + setField(field, entry.getValue()); + } else { + setField( + field, + existingValue + .newBuilderForType() + .mergeFrom(existingValue) + .mergeFrom((Message) entry.getValue()) + .build()); + } + } else { + setField(field, entry.getValue()); + } + } + + mergeUnknownFields(other.getUnknownFields()); + + return (BuilderType) this; + } + + @Override + public BuilderType mergeFrom(final CodedInputStream input) throws IOException { + return mergeFrom(input, ExtensionRegistry.getEmptyRegistry()); + } + + @Override + public BuilderType mergeFrom( + final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) + throws IOException { + boolean discardUnknown = input.shouldDiscardUnknownFields(); + final UnknownFieldSet.Builder unknownFields = + discardUnknown ? null : getUnknownFieldSetBuilder(); + MessageReflection.mergeMessageFrom(this, unknownFields, input, extensionRegistry); + if (unknownFields != null) { + setUnknownFieldSetBuilder(unknownFields); + } + return (BuilderType) this; + } + + protected UnknownFieldSet.Builder getUnknownFieldSetBuilder() { + return UnknownFieldSet.newBuilder(getUnknownFields()); + } + + protected void setUnknownFieldSetBuilder(final UnknownFieldSet.Builder builder) { + setUnknownFields(builder.build()); + } + + @Override + public BuilderType mergeUnknownFields(final UnknownFieldSet unknownFields) { + setUnknownFields( + UnknownFieldSet.newBuilder(getUnknownFields()).mergeFrom(unknownFields).build()); + return (BuilderType) this; + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on an unsupported message type."); + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on an unsupported message type."); + } + + @Override + public String toString() { + return TextFormatInternal.printer().printToString(this); + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + Message message) { + return new UninitializedMessageException(MessageReflection.findMissingFields(message)); + } + + // =============================================================== + // The following definitions seem to be required in order to make javac + // not produce weird errors like: + // + // java/com/google/protobuf/DynamicMessage.java:203: types + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> and + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> are incompatible; both + // define mergeFrom(com.google.protobuf.ByteString), but with unrelated + // return types. + // + // Strangely, these lines are only needed if javac is invoked separately + // on AbstractMessage.java and AbstractMessageLite.java. If javac is + // invoked on both simultaneously, it works. (Or maybe the important + // point is whether or not DynamicMessage.java is compiled together with + // AbstractMessageLite.java -- not sure.) I suspect this is a compiler + // bug. + + @Override + public BuilderType mergeFrom(final ByteString data) throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data); + } + + @Override + public BuilderType mergeFrom( + final ByteString data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data, extensionRegistry); + } + + @Override + public BuilderType mergeFrom(final byte[] data) throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data); + } + + @Override + public BuilderType mergeFrom(final byte[] data, final int off, final int len) + throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data, off, len); + } + + @Override + public BuilderType mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data, extensionRegistry); + } + + @Override + public BuilderType mergeFrom( + final byte[] data, + final int off, + final int len, + final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return (BuilderType) super.mergeFrom(data, off, len, extensionRegistry); + } + + @Override + public BuilderType mergeFrom(final InputStream input) throws IOException { + return (BuilderType) super.mergeFrom(input); + } + + @Override + public BuilderType mergeFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + return (BuilderType) super.mergeFrom(input, extensionRegistry); + } + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashLong(long n) { + return (int) (n ^ (n >>> 32)); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashBoolean(boolean b) { + return b ? 1231 : 1237; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnum(EnumLite e) { + return e.getNumber(); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnumList(List list) { + int hash = 1; + for (EnumLite e : list) { + hash = 31 * hash + hashEnum(e); + } + return hash; + } +} diff --git a/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageLite.java b/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageLite.java index 6a9d7ba..4e3f68f 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageLite.java +++ b/protobuf-api/src/main/java/com/google/protobuf/AbstractMessageLite.java @@ -248,62 +248,6 @@ public BuilderType mergeFrom( return (BuilderType) this; } - /** - * An InputStream implementations which reads from some other InputStream but is limited to a - * particular number of bytes. Used by mergeDelimitedFrom(). This is intentionally - * package-private so that UnknownFieldSet can share it. - */ - static final class LimitedInputStream extends FilterInputStream { - private int limit; - - LimitedInputStream(InputStream in, int limit) { - super(in); - this.limit = limit; - } - - @Override - public int available() throws IOException { - return Math.min(super.available(), limit); - } - - @Override - public int read() throws IOException { - if (limit <= 0) { - return -1; - } - final int result = super.read(); - if (result >= 0) { - --limit; - } - return result; - } - - @Override - public int read(final byte[] b, final int off, int len) throws IOException { - if (limit <= 0) { - return -1; - } - len = Math.min(len, limit); - final int result = super.read(b, off, len); - if (result >= 0) { - limit -= result; - } - return result; - } - - @Override - public long skip(final long n) throws IOException { - // because we take the minimum of an int and a long, result is guaranteed to be - // less than or equal to Integer.MAX_INT so this cast is safe - int result = (int) super.skip(Math.min(n, limit)); - if (result >= 0) { - // if the superclass adheres to the contract for skip, this condition is always true - limit -= result; - } - return result; - } - } - @Override public boolean mergeDelimitedFrom( final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { diff --git a/protobuf-api/src/main/java/com/google/protobuf/AbstractParser.java b/protobuf-api/src/main/java/com/google/protobuf/AbstractParser.java index a1cfc61..8cbe6fa 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/AbstractParser.java +++ b/protobuf-api/src/main/java/com/google/protobuf/AbstractParser.java @@ -7,7 +7,6 @@ package com.google.protobuf; -import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.ByteBuffer; diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Any.java b/protobuf-api/src/main/java/com/google/protobuf/Any.java similarity index 96% rename from protobuf-sdk/src/main/java/com/google/protobuf/Any.java rename to protobuf-api/src/main/java/com/google/protobuf/Any.java index 74c8085..0573c59 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Any.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Any.java @@ -96,12 +96,12 @@ * Protobuf type {@code google.protobuf.Any} */ public final class Any extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Any) AnyOrBuilder { private static final long serialVersionUID = 0L; // Use Any.newBuilder() to construct. - private Any(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Any(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Any() { @@ -122,7 +122,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.AnyProto.internal_static_google_protobuf_Any_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -355,8 +355,8 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(typeUrl_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, typeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(typeUrl_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, typeUrl_); } if (!value_.isEmpty()) { output.writeBytes(2, value_); @@ -370,8 +370,8 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(typeUrl_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, typeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(typeUrl_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, typeUrl_); } if (!value_.isEmpty()) { size += com.google.protobuf.CodedOutputStream @@ -450,20 +450,20 @@ public static com.google.protobuf.Any parseFrom( } public static com.google.protobuf.Any parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Any parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Any parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -471,20 +471,20 @@ public static com.google.protobuf.Any parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Any parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Any parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -504,7 +504,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -600,7 +600,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Any} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Any) com.google.protobuf.AnyOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -609,7 +609,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.AnyProto.internal_static_google_protobuf_Any_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -622,7 +622,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/AnyOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/AnyOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/AnyOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/AnyOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/AnyProto.java b/protobuf-api/src/main/java/com/google/protobuf/AnyProto.java similarity index 92% rename from protobuf-sdk/src/main/java/com/google/protobuf/AnyProto.java rename to protobuf-api/src/main/java/com/google/protobuf/AnyProto.java index 2121cd2..bdb1d0d 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/AnyProto.java +++ b/protobuf-api/src/main/java/com/google/protobuf/AnyProto.java @@ -18,7 +18,7 @@ public static void registerAllExtensions( static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_Any_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_Any_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -43,7 +43,7 @@ public static void registerAllExtensions( internal_static_google_protobuf_Any_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_protobuf_Any_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_Any_descriptor, new java.lang.String[] { "TypeUrl", "Value", }); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Api.java b/protobuf-api/src/main/java/com/google/protobuf/Api.java similarity index 95% rename from protobuf-sdk/src/main/java/com/google/protobuf/Api.java rename to protobuf-api/src/main/java/com/google/protobuf/Api.java index afd6947..9471f31 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Api.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Api.java @@ -20,12 +20,12 @@ * Protobuf type {@code google.protobuf.Api} */ public final class Api extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Api) ApiOrBuilder { private static final long serialVersionUID = 0L; // Use Api.newBuilder() to construct. - private Api(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Api(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Api() { @@ -50,7 +50,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.ApiProto.internal_static_google_protobuf_Api_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -454,8 +454,8 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_); } for (int i = 0; i < methods_.size(); i++) { output.writeMessage(2, methods_.get(i)); @@ -463,8 +463,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) for (int i = 0; i < options_.size(); i++) { output.writeMessage(3, options_.get(i)); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(version_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, version_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(version_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 4, version_); } if (((bitField0_ & 0x00000001) != 0)) { output.writeMessage(5, getSourceContext()); @@ -484,8 +484,8 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_); } for (int i = 0; i < methods_.size(); i++) { size += com.google.protobuf.CodedOutputStream @@ -495,8 +495,8 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeMessageSize(3, options_.get(i)); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(version_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, version_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(version_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(4, version_); } if (((bitField0_ & 0x00000001) != 0)) { size += com.google.protobuf.CodedOutputStream @@ -613,20 +613,20 @@ public static com.google.protobuf.Api parseFrom( } public static com.google.protobuf.Api parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Api parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Api parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -634,20 +634,20 @@ public static com.google.protobuf.Api parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Api parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Api parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -667,7 +667,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -687,7 +687,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Api} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Api) com.google.protobuf.ApiOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -696,7 +696,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.ApiProto.internal_static_google_protobuf_Api_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -709,12 +709,12 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 + if (com.google.protobuf.GeneratedMessageV3Internal .alwaysUseFieldBuilders) { getMethodsFieldBuilder(); getOptionsFieldBuilder(); @@ -906,7 +906,7 @@ public Builder mergeFrom(com.google.protobuf.Api other) { methods_ = other.methods_; bitField0_ = (bitField0_ & ~0x00000002); methodsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getMethodsFieldBuilder() : null; } else { methodsBuilder_.addAllMessages(other.methods_); @@ -932,7 +932,7 @@ public Builder mergeFrom(com.google.protobuf.Api other) { options_ = other.options_; bitField0_ = (bitField0_ & ~0x00000004); optionsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getOptionsFieldBuilder() : null; } else { optionsBuilder_.addAllMessages(other.options_); @@ -966,7 +966,7 @@ public Builder mergeFrom(com.google.protobuf.Api other) { mixins_ = other.mixins_; bitField0_ = (bitField0_ & ~0x00000020); mixinsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getMixinsFieldBuilder() : null; } else { mixinsBuilder_.addAllMessages(other.mixins_); @@ -1186,8 +1186,8 @@ private void ensureMethodsIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Method, com.google.protobuf.Method.Builder, com.google.protobuf.MethodOrBuilder> methodsBuilder_; + private RepeatedFieldBuilderV3Internal< + Method, Method.Builder, MethodOrBuilder> methodsBuilder_; /** *

@@ -1474,12 +1474,12 @@ public com.google.protobuf.Method.Builder addMethodsBuilder(
          getMethodsBuilderList() {
       return getMethodsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Method, com.google.protobuf.Method.Builder, com.google.protobuf.MethodOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Method, Method.Builder, MethodOrBuilder>
         getMethodsFieldBuilder() {
       if (methodsBuilder_ == null) {
-        methodsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Method, com.google.protobuf.Method.Builder, com.google.protobuf.MethodOrBuilder>(
+        methodsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Method, Method.Builder, MethodOrBuilder>(
                 methods_,
                 ((bitField0_ & 0x00000002) != 0),
                 getParentForChildren(),
@@ -1498,8 +1498,8 @@ private void ensureOptionsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder> optionsBuilder_;
 
     /**
      * 
@@ -1786,12 +1786,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000004) != 0),
                 getParentForChildren(),
@@ -1984,8 +1984,8 @@ public Builder setVersionBytes(
     }
 
     private com.google.protobuf.SourceContext sourceContext_;
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> sourceContextBuilder_;
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder> sourceContextBuilder_;
     /**
      * 
      * Source context for the protocol buffer service represented by this
@@ -2135,12 +2135,12 @@ public com.google.protobuf.SourceContextOrBuilder getSourceContextOrBuilder() {
      *
      * .google.protobuf.SourceContext source_context = 5;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder>
         getSourceContextFieldBuilder() {
       if (sourceContextBuilder_ == null) {
-        sourceContextBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder>(
+        sourceContextBuilder_ = new SingleFieldBuilderV3Internal<
+                    SourceContext, SourceContext.Builder, SourceContextOrBuilder>(
                 getSourceContext(),
                 getParentForChildren(),
                 isClean());
@@ -2158,8 +2158,8 @@ private void ensureMixinsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Mixin, com.google.protobuf.Mixin.Builder, com.google.protobuf.MixinOrBuilder> mixinsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Mixin, Mixin.Builder, MixinOrBuilder> mixinsBuilder_;
 
     /**
      * 
@@ -2446,12 +2446,12 @@ public com.google.protobuf.Mixin.Builder addMixinsBuilder(
          getMixinsBuilderList() {
       return getMixinsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Mixin, com.google.protobuf.Mixin.Builder, com.google.protobuf.MixinOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Mixin, Mixin.Builder, MixinOrBuilder>
         getMixinsFieldBuilder() {
       if (mixinsBuilder_ == null) {
-        mixinsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Mixin, com.google.protobuf.Mixin.Builder, com.google.protobuf.MixinOrBuilder>(
+        mixinsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Mixin, Mixin.Builder, MixinOrBuilder>(
                 mixins_,
                 ((bitField0_ & 0x00000020) != 0),
                 getParentForChildren(),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/ApiOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/ApiOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/ApiOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/ApiOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/ApiProto.java b/protobuf-api/src/main/java/com/google/protobuf/ApiProto.java
similarity index 90%
rename from protobuf-sdk/src/main/java/com/google/protobuf/ApiProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/ApiProto.java
index e96e7b2..aa89982 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/ApiProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/ApiProto.java
@@ -18,17 +18,17 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Api_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Api_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Method_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Method_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Mixin_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Mixin_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -68,19 +68,19 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_Api_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_Api_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Api_descriptor,
         new java.lang.String[] { "Name", "Methods", "Options", "Version", "SourceContext", "Mixins", "Syntax", });
     internal_static_google_protobuf_Method_descriptor =
       getDescriptor().getMessageTypes().get(1);
     internal_static_google_protobuf_Method_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Method_descriptor,
         new java.lang.String[] { "Name", "RequestTypeUrl", "RequestStreaming", "ResponseTypeUrl", "ResponseStreaming", "Options", "Syntax", });
     internal_static_google_protobuf_Mixin_descriptor =
       getDescriptor().getMessageTypes().get(2);
     internal_static_google_protobuf_Mixin_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Mixin_descriptor,
         new java.lang.String[] { "Name", "Root", });
     com.google.protobuf.SourceContextProto.getDescriptor();
diff --git a/protobuf-api/src/main/java/com/google/protobuf/ArrayDecoders.java b/protobuf-api/src/main/java/com/google/protobuf/ArrayDecoders.java
index bf5f922..331806b 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/ArrayDecoders.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/ArrayDecoders.java
@@ -765,7 +765,7 @@ static int decodeExtensionOrUnknownField(
       throws IOException {
     final int number = tag >>> 3;
     GeneratedMessageLite.GeneratedExtension extension =
-        registers.extensionRegistry.findLiteExtensionByNumber(defaultInstance, number);
+            (GeneratedMessageLite.GeneratedExtension) registers.extensionRegistry.findLiteExtensionByNumber(defaultInstance, number);
     if (extension == null) {
       return decodeUnknownField(
           tag, data, position, limit, getMutableUnknownFields(message), registers);
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/BoolValue.java b/protobuf-api/src/main/java/com/google/protobuf/BoolValue.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/BoolValue.java
rename to protobuf-api/src/main/java/com/google/protobuf/BoolValue.java
index a015e51..0034f38 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/BoolValue.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/BoolValue.java
@@ -14,12 +14,12 @@
  * Protobuf type {@code google.protobuf.BoolValue}
  */
 public final class BoolValue extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.BoolValue)
     BoolValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use BoolValue.newBuilder() to construct.
-  private BoolValue(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private BoolValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private BoolValue() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.WrappersProto.internal_static_google_protobuf_BoolValue_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -160,20 +160,20 @@ public static com.google.protobuf.BoolValue parseFrom(
   }
   public static com.google.protobuf.BoolValue parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.BoolValue parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.BoolValue parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -181,20 +181,20 @@ public static com.google.protobuf.BoolValue parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.BoolValue parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.BoolValue parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -214,7 +214,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -228,7 +228,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.BoolValue}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.BoolValue)
       com.google.protobuf.BoolValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -237,7 +237,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.WrappersProto.internal_static_google_protobuf_BoolValue_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -250,7 +250,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/BoolValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/BoolValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/BoolValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/BoolValueOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/BytesValue.java b/protobuf-api/src/main/java/com/google/protobuf/BytesValue.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/BytesValue.java
rename to protobuf-api/src/main/java/com/google/protobuf/BytesValue.java
index 44eaefe..9b1a079 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/BytesValue.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/BytesValue.java
@@ -14,12 +14,12 @@
  * Protobuf type {@code google.protobuf.BytesValue}
  */
 public final class BytesValue extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.BytesValue)
     BytesValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use BytesValue.newBuilder() to construct.
-  private BytesValue(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private BytesValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private BytesValue() {
@@ -39,7 +39,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.WrappersProto.internal_static_google_protobuf_BytesValue_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -160,20 +160,20 @@ public static com.google.protobuf.BytesValue parseFrom(
   }
   public static com.google.protobuf.BytesValue parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.BytesValue parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.BytesValue parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -181,20 +181,20 @@ public static com.google.protobuf.BytesValue parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.BytesValue parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.BytesValue parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -214,7 +214,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -228,7 +228,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.BytesValue}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.BytesValue)
       com.google.protobuf.BytesValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -237,7 +237,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.WrappersProto.internal_static_google_protobuf_BytesValue_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -250,7 +250,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/BytesValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/BytesValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/BytesValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/BytesValueOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/CodedOutputStream.java b/protobuf-api/src/main/java/com/google/protobuf/CodedOutputStream.java
index 37bb44a..5131299 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/CodedOutputStream.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/CodedOutputStream.java
@@ -159,7 +159,7 @@ public void useDeterministicSerialization() {
     serializationDeterministic = true;
   }
 
-  boolean isSerializationDeterministic() {
+  public boolean isSerializationDeterministic() {
     return serializationDeterministic;
   }
 
diff --git a/protobuf-api/src/main/java/com/google/protobuf/DescriptorProtos.java b/protobuf-api/src/main/java/com/google/protobuf/DescriptorProtos.java
index bc20823..cb2cec8 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/DescriptorProtos.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/DescriptorProtos.java
@@ -273,7 +273,7 @@ private Edition(int value) {
 
   public interface FileDescriptorSetOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.FileDescriptorSet)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -309,13 +309,13 @@ com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder getFileOrBuild
    * Protobuf type {@code google.protobuf.FileDescriptorSet}
    */
   public static final class FileDescriptorSet extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         FileDescriptorSet> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FileDescriptorSet)
       FileDescriptorSetOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FileDescriptorSet.newBuilder() to construct.
-    private FileDescriptorSet(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private FileDescriptorSet(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private FileDescriptorSet() {
@@ -335,7 +335,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileDescriptorSet_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -407,7 +407,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       for (int i = 0; i < file_.size(); i++) {
@@ -502,20 +502,20 @@ public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -523,20 +523,20 @@ public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseDelimi
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorSet parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -556,7 +556,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -569,7 +569,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FileDescriptorSet}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.FileDescriptorSet, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FileDescriptorSet)
         com.google.protobuf.DescriptorProtos.FileDescriptorSetOrBuilder {
@@ -579,7 +579,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileDescriptorSet_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -592,7 +592,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -687,33 +687,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileDescriptorSet, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileDescriptorSet, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileDescriptorSet, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileDescriptorSet, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileDescriptorSet, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileDescriptorSet, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileDescriptorSet, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileDescriptorSet, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.FileDescriptorSet) {
@@ -745,7 +745,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileDescriptorSet
               file_ = other.file_;
               bitField0_ = (bitField0_ & ~0x00000001);
               fileBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getFileFieldBuilder() : null;
             } else {
               fileBuilder_.addAllMessages(other.file_);
@@ -826,8 +826,8 @@ private void ensureFileIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> fileBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                FileDescriptorProto, FileDescriptorProto.Builder, FileDescriptorProtoOrBuilder> fileBuilder_;
 
       /**
        * repeated .google.protobuf.FileDescriptorProto file = 1;
@@ -958,7 +958,7 @@ public Builder addAllFile(
           java.lang.Iterable values) {
         if (fileBuilder_ == null) {
           ensureFileIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, file_);
           onChanged();
         } else {
@@ -1042,12 +1042,12 @@ public com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder addFileB
            getFileBuilderList() {
         return getFileFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                FileDescriptorProto, FileDescriptorProto.Builder, FileDescriptorProtoOrBuilder>
           getFileFieldBuilder() {
         if (fileBuilder_ == null) {
-          fileBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder>(
+          fileBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        FileDescriptorProto, FileDescriptorProto.Builder, FileDescriptorProtoOrBuilder>(
                   file_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -1531,12 +1531,12 @@ com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder getExtensionO
    * Protobuf type {@code google.protobuf.FileDescriptorProto}
    */
   public static final class FileDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FileDescriptorProto)
       FileDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FileDescriptorProto.newBuilder() to construct.
-    private FileDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private FileDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private FileDescriptorProto() {
@@ -1567,7 +1567,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -2254,13 +2254,13 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, package_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, package_);
       }
       for (int i = 0; i < dependency_.size(); i++) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 3, dependency_.getRaw(i));
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, dependency_.getRaw(i));
       }
       for (int i = 0; i < messageType_.size(); i++) {
         output.writeMessage(4, messageType_.get(i));
@@ -2287,7 +2287,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeInt32(11, weakDependency_.getInt(i));
       }
       if (((bitField0_ & 0x00000010) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 12, syntax_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 12, syntax_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
         output.writeEnum(14, edition_);
@@ -2302,10 +2302,10 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, package_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, package_);
       }
       {
         int dataSize = 0;
@@ -2358,7 +2358,7 @@ public int getSerializedSize() {
         size += 1 * getWeakDependencyList().size();
       }
       if (((bitField0_ & 0x00000010) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(12, syntax_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(12, syntax_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -2524,20 +2524,20 @@ public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseFrom
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -2545,20 +2545,20 @@ public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseDeli
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -2578,7 +2578,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -2590,7 +2590,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FileDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FileDescriptorProto)
         com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -2599,7 +2599,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -2612,12 +2612,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getMessageTypeFieldBuilder();
           getEnumTypeFieldBuilder();
@@ -2899,7 +2899,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileDescriptorProt
               messageType_ = other.messageType_;
               bitField0_ = (bitField0_ & ~0x00000020);
               messageTypeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getMessageTypeFieldBuilder() : null;
             } else {
               messageTypeBuilder_.addAllMessages(other.messageType_);
@@ -2925,7 +2925,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileDescriptorProt
               enumType_ = other.enumType_;
               bitField0_ = (bitField0_ & ~0x00000040);
               enumTypeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getEnumTypeFieldBuilder() : null;
             } else {
               enumTypeBuilder_.addAllMessages(other.enumType_);
@@ -2951,7 +2951,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileDescriptorProt
               service_ = other.service_;
               bitField0_ = (bitField0_ & ~0x00000080);
               serviceBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getServiceFieldBuilder() : null;
             } else {
               serviceBuilder_.addAllMessages(other.service_);
@@ -2977,7 +2977,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileDescriptorProt
               extension_ = other.extension_;
               bitField0_ = (bitField0_ & ~0x00000100);
               extensionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getExtensionFieldBuilder() : null;
             } else {
               extensionBuilder_.addAllMessages(other.extension_);
@@ -3516,7 +3516,7 @@ public Builder addDependency(
       public Builder addAllDependency(
           java.lang.Iterable values) {
         ensureDependencyIsMutable();
-        com.google.protobuf.AbstractMessageLite.Builder.addAll(
+        com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
             values, dependency_);
         bitField0_ |= 0x00000004;
         onChanged();
@@ -3647,7 +3647,7 @@ public Builder addPublicDependency(int value) {
       public Builder addAllPublicDependency(
           java.lang.Iterable values) {
         ensurePublicDependencyIsMutable();
-        com.google.protobuf.AbstractMessageLite.Builder.addAll(
+        com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
             values, publicDependency_);
         bitField0_ |= 0x00000008;
         onChanged();
@@ -3765,7 +3765,7 @@ public Builder addWeakDependency(int value) {
       public Builder addAllWeakDependency(
           java.lang.Iterable values) {
         ensureWeakDependencyIsMutable();
-        com.google.protobuf.AbstractMessageLite.Builder.addAll(
+        com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
             values, weakDependency_);
         bitField0_ |= 0x00000010;
         onChanged();
@@ -3796,8 +3796,8 @@ private void ensureMessageTypeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder> messageTypeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                DescriptorProto, DescriptorProto.Builder, DescriptorProtoOrBuilder> messageTypeBuilder_;
 
       /**
        * 
@@ -3968,7 +3968,7 @@ public Builder addAllMessageType(
           java.lang.Iterable values) {
         if (messageTypeBuilder_ == null) {
           ensureMessageTypeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, messageType_);
           onChanged();
         } else {
@@ -4084,12 +4084,12 @@ public com.google.protobuf.DescriptorProtos.DescriptorProto.Builder addMessageTy
            getMessageTypeBuilderList() {
         return getMessageTypeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                DescriptorProto, DescriptorProto.Builder, DescriptorProtoOrBuilder>
           getMessageTypeFieldBuilder() {
         if (messageTypeBuilder_ == null) {
-          messageTypeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder>(
+          messageTypeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        DescriptorProto, DescriptorProto.Builder, DescriptorProtoOrBuilder>(
                   messageType_,
                   ((bitField0_ & 0x00000020) != 0),
                   getParentForChildren(),
@@ -4108,8 +4108,8 @@ private void ensureEnumTypeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder> enumTypeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder> enumTypeBuilder_;
 
       /**
        * repeated .google.protobuf.EnumDescriptorProto enum_type = 5;
@@ -4240,7 +4240,7 @@ public Builder addAllEnumType(
           java.lang.Iterable values) {
         if (enumTypeBuilder_ == null) {
           ensureEnumTypeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, enumType_);
           onChanged();
         } else {
@@ -4324,12 +4324,12 @@ public com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder addEnumT
            getEnumTypeBuilderList() {
         return getEnumTypeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder>
           getEnumTypeFieldBuilder() {
         if (enumTypeBuilder_ == null) {
-          enumTypeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder>(
+          enumTypeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder>(
                   enumType_,
                   ((bitField0_ & 0x00000040) != 0),
                   getParentForChildren(),
@@ -4348,8 +4348,8 @@ private void ensureServiceIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ServiceDescriptorProto, com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.ServiceDescriptorProtoOrBuilder> serviceBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                ServiceDescriptorProto, ServiceDescriptorProto.Builder, ServiceDescriptorProtoOrBuilder> serviceBuilder_;
 
       /**
        * repeated .google.protobuf.ServiceDescriptorProto service = 6;
@@ -4480,7 +4480,7 @@ public Builder addAllService(
           java.lang.Iterable values) {
         if (serviceBuilder_ == null) {
           ensureServiceIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, service_);
           onChanged();
         } else {
@@ -4564,12 +4564,12 @@ public com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.Builder addSe
            getServiceBuilderList() {
         return getServiceFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ServiceDescriptorProto, com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.ServiceDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                ServiceDescriptorProto, ServiceDescriptorProto.Builder, ServiceDescriptorProtoOrBuilder>
           getServiceFieldBuilder() {
         if (serviceBuilder_ == null) {
-          serviceBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.ServiceDescriptorProto, com.google.protobuf.DescriptorProtos.ServiceDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.ServiceDescriptorProtoOrBuilder>(
+          serviceBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        ServiceDescriptorProto, ServiceDescriptorProto.Builder, ServiceDescriptorProtoOrBuilder>(
                   service_,
                   ((bitField0_ & 0x00000080) != 0),
                   getParentForChildren(),
@@ -4588,8 +4588,8 @@ private void ensureExtensionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> extensionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder> extensionBuilder_;
 
       /**
        * repeated .google.protobuf.FieldDescriptorProto extension = 7;
@@ -4720,7 +4720,7 @@ public Builder addAllExtension(
           java.lang.Iterable values) {
         if (extensionBuilder_ == null) {
           ensureExtensionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, extension_);
           onChanged();
         } else {
@@ -4804,12 +4804,12 @@ public com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder addExte
            getExtensionBuilderList() {
         return getExtensionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>
           getExtensionFieldBuilder() {
         if (extensionBuilder_ == null) {
-          extensionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder>(
+          extensionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>(
                   extension_,
                   ((bitField0_ & 0x00000100) != 0),
                   getParentForChildren(),
@@ -4820,8 +4820,8 @@ public com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder addExte
       }
 
       private com.google.protobuf.DescriptorProtos.FileOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FileOptions, com.google.protobuf.DescriptorProtos.FileOptions.Builder, com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FileOptions, FileOptions.Builder, FileOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.FileOptions options = 8;
        * @return Whether the options field is set.
@@ -4926,12 +4926,12 @@ public com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder getOptionsOrBui
       /**
        * optional .google.protobuf.FileOptions options = 8;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FileOptions, com.google.protobuf.DescriptorProtos.FileOptions.Builder, com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FileOptions, FileOptions.Builder, FileOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FileOptions, com.google.protobuf.DescriptorProtos.FileOptions.Builder, com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        FileOptions, FileOptions.Builder, FileOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -4941,8 +4941,8 @@ public com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder getOptionsOrBui
       }
 
       private com.google.protobuf.DescriptorProtos.SourceCodeInfo sourceCodeInfo_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.SourceCodeInfo, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfoOrBuilder> sourceCodeInfoBuilder_;
+      private SingleFieldBuilderV3Internal<
+                SourceCodeInfo, SourceCodeInfo.Builder, SourceCodeInfoOrBuilder> sourceCodeInfoBuilder_;
       /**
        * 
        * This field contains optional information about the original source code.
@@ -5110,12 +5110,12 @@ public com.google.protobuf.DescriptorProtos.SourceCodeInfoOrBuilder getSourceCod
        *
        * optional .google.protobuf.SourceCodeInfo source_code_info = 9;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.SourceCodeInfo, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfoOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                SourceCodeInfo, SourceCodeInfo.Builder, SourceCodeInfoOrBuilder>
           getSourceCodeInfoFieldBuilder() {
         if (sourceCodeInfoBuilder_ == null) {
-          sourceCodeInfoBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfoOrBuilder>(
+          sourceCodeInfoBuilder_ = new SingleFieldBuilderV3Internal<
+                        SourceCodeInfo, SourceCodeInfo.Builder, SourceCodeInfoOrBuilder>(
                   getSourceCodeInfo(),
                   getParentForChildren(),
                   isClean());
@@ -5654,12 +5654,12 @@ com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRangeOrBuilder getR
    * Protobuf type {@code google.protobuf.DescriptorProto}
    */
   public static final class DescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.DescriptorProto)
       DescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use DescriptorProto.newBuilder() to construct.
-    private DescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private DescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private DescriptorProto() {
@@ -5688,7 +5688,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -5756,12 +5756,12 @@ public interface ExtensionRangeOrBuilder extends
      * Protobuf type {@code google.protobuf.DescriptorProto.ExtensionRange}
      */
     public static final class ExtensionRange extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.DescriptorProto.ExtensionRange)
         ExtensionRangeOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use ExtensionRange.newBuilder() to construct.
-      private ExtensionRange(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private ExtensionRange(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private ExtensionRange() {
@@ -5780,7 +5780,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_ExtensionRange_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -6010,20 +6010,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRang
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -6031,20 +6031,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRang
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -6064,7 +6064,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -6072,7 +6072,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.DescriptorProto.ExtensionRange}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.DescriptorProto.ExtensionRange)
           com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRangeOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -6081,7 +6081,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_ExtensionRange_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -6094,12 +6094,12 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
           maybeForceBuilderInitialization();
         }
         private void maybeForceBuilderInitialization() {
-          if (com.google.protobuf.GeneratedMessageV3
+          if (com.google.protobuf.GeneratedMessageV3Internal
                   .alwaysUseFieldBuilders) {
             getOptionsFieldBuilder();
           }
@@ -6397,8 +6397,8 @@ public Builder clearEnd() {
         }
 
         private com.google.protobuf.DescriptorProtos.ExtensionRangeOptions options_;
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptionsOrBuilder> optionsBuilder_;
+        private SingleFieldBuilderV3Internal<
+                    ExtensionRangeOptions, ExtensionRangeOptions.Builder, ExtensionRangeOptionsOrBuilder> optionsBuilder_;
         /**
          * optional .google.protobuf.ExtensionRangeOptions options = 3;
          * @return Whether the options field is set.
@@ -6503,12 +6503,12 @@ public com.google.protobuf.DescriptorProtos.ExtensionRangeOptionsOrBuilder getOp
         /**
          * optional .google.protobuf.ExtensionRangeOptions options = 3;
          */
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptionsOrBuilder> 
+        private SingleFieldBuilderV3Internal<
+                    ExtensionRangeOptions, ExtensionRangeOptions.Builder, ExtensionRangeOptionsOrBuilder>
             getOptionsFieldBuilder() {
           if (optionsBuilder_ == null) {
-            optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-                com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptionsOrBuilder>(
+            optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                            ExtensionRangeOptions, ExtensionRangeOptions.Builder, ExtensionRangeOptionsOrBuilder>(
                     getOptions(),
                     getParentForChildren(),
                     isClean());
@@ -6632,12 +6632,12 @@ public interface ReservedRangeOrBuilder extends
      * Protobuf type {@code google.protobuf.DescriptorProto.ReservedRange}
      */
     public static final class ReservedRange extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.DescriptorProto.ReservedRange)
         ReservedRangeOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use ReservedRange.newBuilder() to construct.
-      private ReservedRange(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private ReservedRange(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private ReservedRange() {
@@ -6656,7 +6656,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_ReservedRange_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -6838,20 +6838,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -6859,20 +6859,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -6892,7 +6892,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -6906,7 +6906,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.DescriptorProto.ReservedRange}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.DescriptorProto.ReservedRange)
           com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRangeOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -6915,7 +6915,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_ReservedRange_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -6928,7 +6928,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -7738,7 +7738,7 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       for (int i = 0; i < field_.size(); i++) {
         output.writeMessage(2, field_.get(i));
@@ -7765,7 +7765,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeMessage(9, reservedRange_.get(i));
       }
       for (int i = 0; i < reservedName_.size(); i++) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 10, reservedName_.getRaw(i));
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 10, reservedName_.getRaw(i));
       }
       getUnknownFields().writeTo(output);
     }
@@ -7777,7 +7777,7 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       for (int i = 0; i < field_.size(); i++) {
         size += com.google.protobuf.CodedOutputStream
@@ -7950,20 +7950,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.DescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.DescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.DescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -7971,20 +7971,20 @@ public static com.google.protobuf.DescriptorProtos.DescriptorProto parseDelimite
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.DescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.DescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -8004,7 +8004,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -8016,7 +8016,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.DescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.DescriptorProto)
         com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -8025,7 +8025,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_DescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -8038,12 +8038,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFieldFieldBuilder();
           getExtensionFieldBuilder();
@@ -8302,7 +8302,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               field_ = other.field_;
               bitField0_ = (bitField0_ & ~0x00000002);
               fieldBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getFieldFieldBuilder() : null;
             } else {
               fieldBuilder_.addAllMessages(other.field_);
@@ -8328,7 +8328,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               extension_ = other.extension_;
               bitField0_ = (bitField0_ & ~0x00000004);
               extensionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getExtensionFieldBuilder() : null;
             } else {
               extensionBuilder_.addAllMessages(other.extension_);
@@ -8354,7 +8354,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               nestedType_ = other.nestedType_;
               bitField0_ = (bitField0_ & ~0x00000008);
               nestedTypeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getNestedTypeFieldBuilder() : null;
             } else {
               nestedTypeBuilder_.addAllMessages(other.nestedType_);
@@ -8380,7 +8380,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               enumType_ = other.enumType_;
               bitField0_ = (bitField0_ & ~0x00000010);
               enumTypeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getEnumTypeFieldBuilder() : null;
             } else {
               enumTypeBuilder_.addAllMessages(other.enumType_);
@@ -8406,7 +8406,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               extensionRange_ = other.extensionRange_;
               bitField0_ = (bitField0_ & ~0x00000020);
               extensionRangeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getExtensionRangeFieldBuilder() : null;
             } else {
               extensionRangeBuilder_.addAllMessages(other.extensionRange_);
@@ -8432,7 +8432,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               oneofDecl_ = other.oneofDecl_;
               bitField0_ = (bitField0_ & ~0x00000040);
               oneofDeclBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getOneofDeclFieldBuilder() : null;
             } else {
               oneofDeclBuilder_.addAllMessages(other.oneofDecl_);
@@ -8461,7 +8461,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.DescriptorProto ot
               reservedRange_ = other.reservedRange_;
               bitField0_ = (bitField0_ & ~0x00000100);
               reservedRangeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getReservedRangeFieldBuilder() : null;
             } else {
               reservedRangeBuilder_.addAllMessages(other.reservedRange_);
@@ -8754,8 +8754,8 @@ private void ensureFieldIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> fieldBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder> fieldBuilder_;
 
       /**
        * repeated .google.protobuf.FieldDescriptorProto field = 2;
@@ -8886,7 +8886,7 @@ public Builder addAllField(
           java.lang.Iterable values) {
         if (fieldBuilder_ == null) {
           ensureFieldIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, field_);
           onChanged();
         } else {
@@ -8970,12 +8970,12 @@ public com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder addFiel
            getFieldBuilderList() {
         return getFieldFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>
           getFieldFieldBuilder() {
         if (fieldBuilder_ == null) {
-          fieldBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder>(
+          fieldBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>(
                   field_,
                   ((bitField0_ & 0x00000002) != 0),
                   getParentForChildren(),
@@ -8994,8 +8994,8 @@ private void ensureExtensionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> extensionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder> extensionBuilder_;
 
       /**
        * repeated .google.protobuf.FieldDescriptorProto extension = 6;
@@ -9126,7 +9126,7 @@ public Builder addAllExtension(
           java.lang.Iterable values) {
         if (extensionBuilder_ == null) {
           ensureExtensionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, extension_);
           onChanged();
         } else {
@@ -9210,12 +9210,12 @@ public com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder addExte
            getExtensionBuilderList() {
         return getExtensionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>
           getExtensionFieldBuilder() {
         if (extensionBuilder_ == null) {
-          extensionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldDescriptorProto, com.google.protobuf.DescriptorProtos.FieldDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder>(
+          extensionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        FieldDescriptorProto, FieldDescriptorProto.Builder, FieldDescriptorProtoOrBuilder>(
                   extension_,
                   ((bitField0_ & 0x00000004) != 0),
                   getParentForChildren(),
@@ -9234,8 +9234,8 @@ private void ensureNestedTypeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder> nestedTypeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                DescriptorProto, Builder, DescriptorProtoOrBuilder> nestedTypeBuilder_;
 
       /**
        * repeated .google.protobuf.DescriptorProto nested_type = 3;
@@ -9366,7 +9366,7 @@ public Builder addAllNestedType(
           java.lang.Iterable values) {
         if (nestedTypeBuilder_ == null) {
           ensureNestedTypeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, nestedType_);
           onChanged();
         } else {
@@ -9450,12 +9450,12 @@ public com.google.protobuf.DescriptorProtos.DescriptorProto.Builder addNestedTyp
            getNestedTypeBuilderList() {
         return getNestedTypeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                DescriptorProto, Builder, DescriptorProtoOrBuilder>
           getNestedTypeFieldBuilder() {
         if (nestedTypeBuilder_ == null) {
-          nestedTypeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.DescriptorProto, com.google.protobuf.DescriptorProtos.DescriptorProto.Builder, com.google.protobuf.DescriptorProtos.DescriptorProtoOrBuilder>(
+          nestedTypeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        DescriptorProto, Builder, DescriptorProtoOrBuilder>(
                   nestedType_,
                   ((bitField0_ & 0x00000008) != 0),
                   getParentForChildren(),
@@ -9474,8 +9474,8 @@ private void ensureEnumTypeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder> enumTypeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder> enumTypeBuilder_;
 
       /**
        * repeated .google.protobuf.EnumDescriptorProto enum_type = 4;
@@ -9606,7 +9606,7 @@ public Builder addAllEnumType(
           java.lang.Iterable values) {
         if (enumTypeBuilder_ == null) {
           ensureEnumTypeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, enumType_);
           onChanged();
         } else {
@@ -9690,12 +9690,12 @@ public com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder addEnumT
            getEnumTypeBuilderList() {
         return getEnumTypeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder>
           getEnumTypeFieldBuilder() {
         if (enumTypeBuilder_ == null) {
-          enumTypeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumDescriptorProto, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder>(
+          enumTypeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        EnumDescriptorProto, EnumDescriptorProto.Builder, EnumDescriptorProtoOrBuilder>(
                   enumType_,
                   ((bitField0_ & 0x00000010) != 0),
                   getParentForChildren(),
@@ -9714,8 +9714,8 @@ private void ensureExtensionRangeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRangeOrBuilder> extensionRangeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                ExtensionRange, ExtensionRange.Builder, ExtensionRangeOrBuilder> extensionRangeBuilder_;
 
       /**
        * repeated .google.protobuf.DescriptorProto.ExtensionRange extension_range = 5;
@@ -9846,7 +9846,7 @@ public Builder addAllExtensionRange(
           java.lang.Iterable values) {
         if (extensionRangeBuilder_ == null) {
           ensureExtensionRangeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, extensionRange_);
           onChanged();
         } else {
@@ -9930,12 +9930,12 @@ public com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange.Build
            getExtensionRangeBuilderList() {
         return getExtensionRangeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRangeOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                ExtensionRange, ExtensionRange.Builder, ExtensionRangeOrBuilder>
           getExtensionRangeFieldBuilder() {
         if (extensionRangeBuilder_ == null) {
-          extensionRangeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ExtensionRangeOrBuilder>(
+          extensionRangeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        ExtensionRange, ExtensionRange.Builder, ExtensionRangeOrBuilder>(
                   extensionRange_,
                   ((bitField0_ & 0x00000020) != 0),
                   getParentForChildren(),
@@ -9954,8 +9954,8 @@ private void ensureOneofDeclIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.OneofDescriptorProto, com.google.protobuf.DescriptorProtos.OneofDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.OneofDescriptorProtoOrBuilder> oneofDeclBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                OneofDescriptorProto, OneofDescriptorProto.Builder, OneofDescriptorProtoOrBuilder> oneofDeclBuilder_;
 
       /**
        * repeated .google.protobuf.OneofDescriptorProto oneof_decl = 8;
@@ -10086,7 +10086,7 @@ public Builder addAllOneofDecl(
           java.lang.Iterable values) {
         if (oneofDeclBuilder_ == null) {
           ensureOneofDeclIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, oneofDecl_);
           onChanged();
         } else {
@@ -10170,12 +10170,12 @@ public com.google.protobuf.DescriptorProtos.OneofDescriptorProto.Builder addOneo
            getOneofDeclBuilderList() {
         return getOneofDeclFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.OneofDescriptorProto, com.google.protobuf.DescriptorProtos.OneofDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.OneofDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                OneofDescriptorProto, OneofDescriptorProto.Builder, OneofDescriptorProtoOrBuilder>
           getOneofDeclFieldBuilder() {
         if (oneofDeclBuilder_ == null) {
-          oneofDeclBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.OneofDescriptorProto, com.google.protobuf.DescriptorProtos.OneofDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.OneofDescriptorProtoOrBuilder>(
+          oneofDeclBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        OneofDescriptorProto, OneofDescriptorProto.Builder, OneofDescriptorProtoOrBuilder>(
                   oneofDecl_,
                   ((bitField0_ & 0x00000040) != 0),
                   getParentForChildren(),
@@ -10186,8 +10186,8 @@ public com.google.protobuf.DescriptorProtos.OneofDescriptorProto.Builder addOneo
       }
 
       private com.google.protobuf.DescriptorProtos.MessageOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MessageOptions, com.google.protobuf.DescriptorProtos.MessageOptions.Builder, com.google.protobuf.DescriptorProtos.MessageOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                MessageOptions, MessageOptions.Builder, MessageOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.MessageOptions options = 7;
        * @return Whether the options field is set.
@@ -10292,12 +10292,12 @@ public com.google.protobuf.DescriptorProtos.MessageOptionsOrBuilder getOptionsOr
       /**
        * optional .google.protobuf.MessageOptions options = 7;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MessageOptions, com.google.protobuf.DescriptorProtos.MessageOptions.Builder, com.google.protobuf.DescriptorProtos.MessageOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                MessageOptions, MessageOptions.Builder, MessageOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.MessageOptions, com.google.protobuf.DescriptorProtos.MessageOptions.Builder, com.google.protobuf.DescriptorProtos.MessageOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        MessageOptions, MessageOptions.Builder, MessageOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -10315,8 +10315,8 @@ private void ensureReservedRangeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRangeOrBuilder> reservedRangeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                ReservedRange, ReservedRange.Builder, ReservedRangeOrBuilder> reservedRangeBuilder_;
 
       /**
        * repeated .google.protobuf.DescriptorProto.ReservedRange reserved_range = 9;
@@ -10447,7 +10447,7 @@ public Builder addAllReservedRange(
           java.lang.Iterable values) {
         if (reservedRangeBuilder_ == null) {
           ensureReservedRangeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, reservedRange_);
           onChanged();
         } else {
@@ -10531,12 +10531,12 @@ public com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange.Builde
            getReservedRangeBuilderList() {
         return getReservedRangeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRangeOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                ReservedRange, ReservedRange.Builder, ReservedRangeOrBuilder>
           getReservedRangeFieldBuilder() {
         if (reservedRangeBuilder_ == null) {
-          reservedRangeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRange.Builder, com.google.protobuf.DescriptorProtos.DescriptorProto.ReservedRangeOrBuilder>(
+          reservedRangeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        ReservedRange, ReservedRange.Builder, ReservedRangeOrBuilder>(
                   reservedRange_,
                   ((bitField0_ & 0x00000100) != 0),
                   getParentForChildren(),
@@ -10659,7 +10659,7 @@ public Builder addReservedName(
       public Builder addAllReservedName(
           java.lang.Iterable values) {
         ensureReservedNameIsMutable();
-        com.google.protobuf.AbstractMessageLite.Builder.addAll(
+        com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
             values, reservedName_);
         bitField0_ |= 0x00000200;
         onChanged();
@@ -10766,7 +10766,7 @@ public com.google.protobuf.DescriptorProtos.DescriptorProto getDefaultInstanceFo
 
   public interface ExtensionRangeOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.ExtensionRangeOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -10921,13 +10921,13 @@ com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.DeclarationOrBuilder
    * Protobuf type {@code google.protobuf.ExtensionRangeOptions}
    */
   public static final class ExtensionRangeOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         ExtensionRangeOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.ExtensionRangeOptions)
       ExtensionRangeOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use ExtensionRangeOptions.newBuilder() to construct.
-    private ExtensionRangeOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private ExtensionRangeOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private ExtensionRangeOptions() {
@@ -10949,7 +10949,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ExtensionRangeOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -11202,12 +11202,12 @@ public interface DeclarationOrBuilder extends
      * Protobuf type {@code google.protobuf.ExtensionRangeOptions.Declaration}
      */
     public static final class Declaration extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.ExtensionRangeOptions.Declaration)
         DeclarationOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use Declaration.newBuilder() to construct.
-      private Declaration(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private Declaration(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private Declaration() {
@@ -11228,7 +11228,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ExtensionRangeOptions_Declaration_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -11472,10 +11472,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
           output.writeInt32(1, number_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 2, fullName_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, fullName_);
         }
         if (((bitField0_ & 0x00000004) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 3, type_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, type_);
         }
         if (((bitField0_ & 0x00000008) != 0)) {
           output.writeBool(5, reserved_);
@@ -11497,10 +11497,10 @@ public int getSerializedSize() {
             .computeInt32Size(1, number_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, fullName_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, fullName_);
         }
         if (((bitField0_ & 0x00000004) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, type_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, type_);
         }
         if (((bitField0_ & 0x00000008) != 0)) {
           size += com.google.protobuf.CodedOutputStream
@@ -11622,20 +11622,20 @@ public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declara
       }
       public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -11643,20 +11643,20 @@ public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declara
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -11676,7 +11676,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -11684,7 +11684,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.ExtensionRangeOptions.Declaration}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.ExtensionRangeOptions.Declaration)
           com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.DeclarationOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -11693,7 +11693,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ExtensionRangeOptions_Declaration_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -11706,7 +11706,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -12607,7 +12607,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       for (int i = 0; i < declaration_.size(); i++) {
@@ -12746,20 +12746,20 @@ public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseFr
     }
     public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -12767,20 +12767,20 @@ public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseDe
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ExtensionRangeOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -12800,7 +12800,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -12808,7 +12808,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.ExtensionRangeOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.ExtensionRangeOptions)
         com.google.protobuf.DescriptorProtos.ExtensionRangeOptionsOrBuilder {
@@ -12818,7 +12818,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ExtensionRangeOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -12831,12 +12831,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getUninterpretedOptionFieldBuilder();
           getDeclarationFieldBuilder();
@@ -12968,33 +12968,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.ExtensionRangeOptions) {
@@ -13026,7 +13026,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.ExtensionRangeOpti
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000001);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -13052,7 +13052,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.ExtensionRangeOpti
               declaration_ = other.declaration_;
               bitField0_ = (bitField0_ & ~0x00000002);
               declarationBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getDeclarationFieldBuilder() : null;
             } else {
               declarationBuilder_.addAllMessages(other.declaration_);
@@ -13176,8 +13176,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -13348,7 +13348,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -13464,12 +13464,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -13488,8 +13488,8 @@ private void ensureDeclarationIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.DeclarationOrBuilder> declarationBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                Declaration, Declaration.Builder, DeclarationOrBuilder> declarationBuilder_;
 
       /**
        * 
@@ -13680,7 +13680,7 @@ public Builder addAllDeclaration(
           java.lang.Iterable values) {
         if (declarationBuilder_ == null) {
           ensureDeclarationIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, declaration_);
           onChanged();
         } else {
@@ -13812,12 +13812,12 @@ public com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration.Bu
            getDeclarationBuilderList() {
         return getDeclarationFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.DeclarationOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                Declaration, Declaration.Builder, DeclarationOrBuilder>
           getDeclarationFieldBuilder() {
         if (declarationBuilder_ == null) {
-          declarationBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration.Builder, com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.DeclarationOrBuilder>(
+          declarationBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        Declaration, Declaration.Builder, DeclarationOrBuilder>(
                   declaration_,
                   ((bitField0_ & 0x00000002) != 0),
                   getParentForChildren(),
@@ -13828,8 +13828,8 @@ public com.google.protobuf.DescriptorProtos.ExtensionRangeOptions.Declaration.Bu
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -13970,12 +13970,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 50;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -14429,12 +14429,12 @@ public interface FieldDescriptorProtoOrBuilder extends
    * Protobuf type {@code google.protobuf.FieldDescriptorProto}
    */
   public static final class FieldDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FieldDescriptorProto)
       FieldDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FieldDescriptorProto.newBuilder() to construct.
-    private FieldDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private FieldDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private FieldDescriptorProto() {
@@ -14460,7 +14460,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -15445,10 +15445,10 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, extendee_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, extendee_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         output.writeInt32(3, number_);
@@ -15460,10 +15460,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeEnum(5, type_);
       }
       if (((bitField0_ & 0x00000010) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 6, typeName_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 6, typeName_);
       }
       if (((bitField0_ & 0x00000040) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 7, defaultValue_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 7, defaultValue_);
       }
       if (((bitField0_ & 0x00000200) != 0)) {
         output.writeMessage(8, getOptions());
@@ -15472,7 +15472,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeInt32(9, oneofIndex_);
       }
       if (((bitField0_ & 0x00000100) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 10, jsonName_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 10, jsonName_);
       }
       if (((bitField0_ & 0x00000400) != 0)) {
         output.writeBool(17, proto3Optional_);
@@ -15487,10 +15487,10 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, extendee_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, extendee_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -15505,10 +15505,10 @@ public int getSerializedSize() {
           .computeEnumSize(5, type_);
       }
       if (((bitField0_ & 0x00000010) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, typeName_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(6, typeName_);
       }
       if (((bitField0_ & 0x00000040) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, defaultValue_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(7, defaultValue_);
       }
       if (((bitField0_ & 0x00000200) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -15519,7 +15519,7 @@ public int getSerializedSize() {
           .computeInt32Size(9, oneofIndex_);
       }
       if (((bitField0_ & 0x00000100) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, jsonName_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(10, jsonName_);
       }
       if (((bitField0_ & 0x00000400) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -15688,20 +15688,20 @@ public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseFro
     }
     public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -15709,20 +15709,20 @@ public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseDel
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FieldDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -15742,7 +15742,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -15754,7 +15754,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FieldDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FieldDescriptorProto)
         com.google.protobuf.DescriptorProtos.FieldDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -15763,7 +15763,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -15776,12 +15776,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getOptionsFieldBuilder();
         }
@@ -16861,8 +16861,8 @@ public Builder setJsonNameBytes(
       }
 
       private com.google.protobuf.DescriptorProtos.FieldOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions, com.google.protobuf.DescriptorProtos.FieldOptions.Builder, com.google.protobuf.DescriptorProtos.FieldOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FieldOptions, FieldOptions.Builder, FieldOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.FieldOptions options = 8;
        * @return Whether the options field is set.
@@ -16967,12 +16967,12 @@ public com.google.protobuf.DescriptorProtos.FieldOptionsOrBuilder getOptionsOrBu
       /**
        * optional .google.protobuf.FieldOptions options = 8;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions, com.google.protobuf.DescriptorProtos.FieldOptions.Builder, com.google.protobuf.DescriptorProtos.FieldOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FieldOptions, FieldOptions.Builder, FieldOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldOptions, com.google.protobuf.DescriptorProtos.FieldOptions.Builder, com.google.protobuf.DescriptorProtos.FieldOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        FieldOptions, FieldOptions.Builder, FieldOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -17224,12 +17224,12 @@ public interface OneofDescriptorProtoOrBuilder extends
    * Protobuf type {@code google.protobuf.OneofDescriptorProto}
    */
   public static final class OneofDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.OneofDescriptorProto)
       OneofDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use OneofDescriptorProto.newBuilder() to construct.
-    private OneofDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private OneofDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private OneofDescriptorProto() {
@@ -17249,7 +17249,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_OneofDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -17353,7 +17353,7 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         output.writeMessage(2, getOptions());
@@ -17368,7 +17368,7 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -17457,20 +17457,20 @@ public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseFro
     }
     public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -17478,20 +17478,20 @@ public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseDel
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.OneofDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -17511,7 +17511,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -17523,7 +17523,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.OneofDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.OneofDescriptorProto)
         com.google.protobuf.DescriptorProtos.OneofDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -17532,7 +17532,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_OneofDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -17545,12 +17545,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getOptionsFieldBuilder();
         }
@@ -17805,8 +17805,8 @@ public Builder setNameBytes(
       }
 
       private com.google.protobuf.DescriptorProtos.OneofOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.OneofOptions, com.google.protobuf.DescriptorProtos.OneofOptions.Builder, com.google.protobuf.DescriptorProtos.OneofOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                OneofOptions, OneofOptions.Builder, OneofOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.OneofOptions options = 2;
        * @return Whether the options field is set.
@@ -17911,12 +17911,12 @@ public com.google.protobuf.DescriptorProtos.OneofOptionsOrBuilder getOptionsOrBu
       /**
        * optional .google.protobuf.OneofOptions options = 2;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.OneofOptions, com.google.protobuf.DescriptorProtos.OneofOptions.Builder, com.google.protobuf.DescriptorProtos.OneofOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                OneofOptions, OneofOptions.Builder, OneofOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.OneofOptions, com.google.protobuf.DescriptorProtos.OneofOptions.Builder, com.google.protobuf.DescriptorProtos.OneofOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        OneofOptions, OneofOptions.Builder, OneofOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -18155,12 +18155,12 @@ com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRangeOrBuil
    * Protobuf type {@code google.protobuf.EnumDescriptorProto}
    */
   public static final class EnumDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.EnumDescriptorProto)
       EnumDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use EnumDescriptorProto.newBuilder() to construct.
-    private EnumDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private EnumDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private EnumDescriptorProto() {
@@ -18184,7 +18184,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -18246,12 +18246,12 @@ public interface EnumReservedRangeOrBuilder extends
      * Protobuf type {@code google.protobuf.EnumDescriptorProto.EnumReservedRange}
      */
     public static final class EnumReservedRange extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.EnumDescriptorProto.EnumReservedRange)
         EnumReservedRangeOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use EnumReservedRange.newBuilder() to construct.
-      private EnumReservedRange(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private EnumReservedRange(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private EnumReservedRange() {
@@ -18270,7 +18270,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -18452,20 +18452,20 @@ public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReser
       }
       public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -18473,20 +18473,20 @@ public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReser
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -18506,7 +18506,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -18523,7 +18523,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.EnumDescriptorProto.EnumReservedRange}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.EnumDescriptorProto.EnumReservedRange)
           com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRangeOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -18532,7 +18532,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -18545,7 +18545,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -19150,7 +19150,7 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       for (int i = 0; i < value_.size(); i++) {
         output.writeMessage(2, value_.get(i));
@@ -19162,7 +19162,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeMessage(4, reservedRange_.get(i));
       }
       for (int i = 0; i < reservedName_.size(); i++) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 5, reservedName_.getRaw(i));
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 5, reservedName_.getRaw(i));
       }
       getUnknownFields().writeTo(output);
     }
@@ -19174,7 +19174,7 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       for (int i = 0; i < value_.size(); i++) {
         size += com.google.protobuf.CodedOutputStream
@@ -19297,20 +19297,20 @@ public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseFrom
     }
     public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -19318,20 +19318,20 @@ public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseDeli
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -19351,7 +19351,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -19363,7 +19363,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.EnumDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.EnumDescriptorProto)
         com.google.protobuf.DescriptorProtos.EnumDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -19372,7 +19372,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -19385,12 +19385,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getValueFieldBuilder();
           getOptionsFieldBuilder();
@@ -19564,7 +19564,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.EnumDescriptorProt
               value_ = other.value_;
               bitField0_ = (bitField0_ & ~0x00000002);
               valueBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getValueFieldBuilder() : null;
             } else {
               valueBuilder_.addAllMessages(other.value_);
@@ -19593,7 +19593,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.EnumDescriptorProt
               reservedRange_ = other.reservedRange_;
               bitField0_ = (bitField0_ & ~0x00000008);
               reservedRangeBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getReservedRangeFieldBuilder() : null;
             } else {
               reservedRangeBuilder_.addAllMessages(other.reservedRange_);
@@ -19796,8 +19796,8 @@ private void ensureValueIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProtoOrBuilder> valueBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                EnumValueDescriptorProto, EnumValueDescriptorProto.Builder, EnumValueDescriptorProtoOrBuilder> valueBuilder_;
 
       /**
        * repeated .google.protobuf.EnumValueDescriptorProto value = 2;
@@ -19928,7 +19928,7 @@ public Builder addAllValue(
           java.lang.Iterable values) {
         if (valueBuilder_ == null) {
           ensureValueIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, value_);
           onChanged();
         } else {
@@ -20012,12 +20012,12 @@ public com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto.Builder add
            getValueBuilderList() {
         return getValueFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                EnumValueDescriptorProto, EnumValueDescriptorProto.Builder, EnumValueDescriptorProtoOrBuilder>
           getValueFieldBuilder() {
         if (valueBuilder_ == null) {
-          valueBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.EnumValueDescriptorProtoOrBuilder>(
+          valueBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        EnumValueDescriptorProto, EnumValueDescriptorProto.Builder, EnumValueDescriptorProtoOrBuilder>(
                   value_,
                   ((bitField0_ & 0x00000002) != 0),
                   getParentForChildren(),
@@ -20028,8 +20028,8 @@ public com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto.Builder add
       }
 
       private com.google.protobuf.DescriptorProtos.EnumOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumOptions, com.google.protobuf.DescriptorProtos.EnumOptions.Builder, com.google.protobuf.DescriptorProtos.EnumOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                EnumOptions, EnumOptions.Builder, EnumOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.EnumOptions options = 3;
        * @return Whether the options field is set.
@@ -20134,12 +20134,12 @@ public com.google.protobuf.DescriptorProtos.EnumOptionsOrBuilder getOptionsOrBui
       /**
        * optional .google.protobuf.EnumOptions options = 3;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumOptions, com.google.protobuf.DescriptorProtos.EnumOptions.Builder, com.google.protobuf.DescriptorProtos.EnumOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                EnumOptions, EnumOptions.Builder, EnumOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumOptions, com.google.protobuf.DescriptorProtos.EnumOptions.Builder, com.google.protobuf.DescriptorProtos.EnumOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        EnumOptions, EnumOptions.Builder, EnumOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -20157,8 +20157,8 @@ private void ensureReservedRangeIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRangeOrBuilder> reservedRangeBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                EnumReservedRange, EnumReservedRange.Builder, EnumReservedRangeOrBuilder> reservedRangeBuilder_;
 
       /**
        * 
@@ -20349,7 +20349,7 @@ public Builder addAllReservedRange(
           java.lang.Iterable values) {
         if (reservedRangeBuilder_ == null) {
           ensureReservedRangeIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, reservedRange_);
           onChanged();
         } else {
@@ -20481,12 +20481,12 @@ public com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRang
            getReservedRangeBuilderList() {
         return getReservedRangeFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRangeOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                EnumReservedRange, EnumReservedRange.Builder, EnumReservedRangeOrBuilder>
           getReservedRangeFieldBuilder() {
         if (reservedRangeBuilder_ == null) {
-          reservedRangeBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRange.Builder, com.google.protobuf.DescriptorProtos.EnumDescriptorProto.EnumReservedRangeOrBuilder>(
+          reservedRangeBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        EnumReservedRange, EnumReservedRange.Builder, EnumReservedRangeOrBuilder>(
                   reservedRange_,
                   ((bitField0_ & 0x00000008) != 0),
                   getParentForChildren(),
@@ -20609,7 +20609,7 @@ public Builder addReservedName(
       public Builder addAllReservedName(
           java.lang.Iterable values) {
         ensureReservedNameIsMutable();
-        com.google.protobuf.AbstractMessageLite.Builder.addAll(
+        com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
             values, reservedName_);
         bitField0_ |= 0x00000010;
         onChanged();
@@ -20769,12 +20769,12 @@ public interface EnumValueDescriptorProtoOrBuilder extends
    * Protobuf type {@code google.protobuf.EnumValueDescriptorProto}
    */
   public static final class EnumValueDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.EnumValueDescriptorProto)
       EnumValueDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use EnumValueDescriptorProto.newBuilder() to construct.
-    private EnumValueDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private EnumValueDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private EnumValueDescriptorProto() {
@@ -20794,7 +20794,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumValueDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -20917,7 +20917,7 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         output.writeInt32(2, number_);
@@ -20935,7 +20935,7 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -21037,20 +21037,20 @@ public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto pars
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -21058,20 +21058,20 @@ public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto pars
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -21091,7 +21091,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -21103,7 +21103,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.EnumValueDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.EnumValueDescriptorProto)
         com.google.protobuf.DescriptorProtos.EnumValueDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -21112,7 +21112,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumValueDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -21125,12 +21125,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getOptionsFieldBuilder();
         }
@@ -21438,8 +21438,8 @@ public Builder clearNumber() {
       }
 
       private com.google.protobuf.DescriptorProtos.EnumValueOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumValueOptions, com.google.protobuf.DescriptorProtos.EnumValueOptions.Builder, com.google.protobuf.DescriptorProtos.EnumValueOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                EnumValueOptions, EnumValueOptions.Builder, EnumValueOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.EnumValueOptions options = 3;
        * @return Whether the options field is set.
@@ -21544,12 +21544,12 @@ public com.google.protobuf.DescriptorProtos.EnumValueOptionsOrBuilder getOptions
       /**
        * optional .google.protobuf.EnumValueOptions options = 3;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.EnumValueOptions, com.google.protobuf.DescriptorProtos.EnumValueOptions.Builder, com.google.protobuf.DescriptorProtos.EnumValueOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                EnumValueOptions, EnumValueOptions.Builder, EnumValueOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.EnumValueOptions, com.google.protobuf.DescriptorProtos.EnumValueOptions.Builder, com.google.protobuf.DescriptorProtos.EnumValueOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        EnumValueOptions, EnumValueOptions.Builder, EnumValueOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -21689,12 +21689,12 @@ com.google.protobuf.DescriptorProtos.MethodDescriptorProtoOrBuilder getMethodOrB
    * Protobuf type {@code google.protobuf.ServiceDescriptorProto}
    */
   public static final class ServiceDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.ServiceDescriptorProto)
       ServiceDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use ServiceDescriptorProto.newBuilder() to construct.
-    private ServiceDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private ServiceDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private ServiceDescriptorProto() {
@@ -21715,7 +21715,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ServiceDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -21866,7 +21866,7 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       for (int i = 0; i < method_.size(); i++) {
         output.writeMessage(2, method_.get(i));
@@ -21884,7 +21884,7 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       for (int i = 0; i < method_.size(); i++) {
         size += com.google.protobuf.CodedOutputStream
@@ -21983,20 +21983,20 @@ public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseF
     }
     public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -22004,20 +22004,20 @@ public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseD
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -22037,7 +22037,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -22049,7 +22049,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.ServiceDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.ServiceDescriptorProto)
         com.google.protobuf.DescriptorProtos.ServiceDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -22058,7 +22058,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ServiceDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -22071,12 +22071,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getMethodFieldBuilder();
           getOptionsFieldBuilder();
@@ -22227,7 +22227,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.ServiceDescriptorP
               method_ = other.method_;
               bitField0_ = (bitField0_ & ~0x00000002);
               methodBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getMethodFieldBuilder() : null;
             } else {
               methodBuilder_.addAllMessages(other.method_);
@@ -22404,8 +22404,8 @@ private void ensureMethodIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MethodDescriptorProto, com.google.protobuf.DescriptorProtos.MethodDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.MethodDescriptorProtoOrBuilder> methodBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                MethodDescriptorProto, MethodDescriptorProto.Builder, MethodDescriptorProtoOrBuilder> methodBuilder_;
 
       /**
        * repeated .google.protobuf.MethodDescriptorProto method = 2;
@@ -22536,7 +22536,7 @@ public Builder addAllMethod(
           java.lang.Iterable values) {
         if (methodBuilder_ == null) {
           ensureMethodIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, method_);
           onChanged();
         } else {
@@ -22620,12 +22620,12 @@ public com.google.protobuf.DescriptorProtos.MethodDescriptorProto.Builder addMet
            getMethodBuilderList() {
         return getMethodFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MethodDescriptorProto, com.google.protobuf.DescriptorProtos.MethodDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.MethodDescriptorProtoOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                MethodDescriptorProto, MethodDescriptorProto.Builder, MethodDescriptorProtoOrBuilder>
           getMethodFieldBuilder() {
         if (methodBuilder_ == null) {
-          methodBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.MethodDescriptorProto, com.google.protobuf.DescriptorProtos.MethodDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.MethodDescriptorProtoOrBuilder>(
+          methodBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        MethodDescriptorProto, MethodDescriptorProto.Builder, MethodDescriptorProtoOrBuilder>(
                   method_,
                   ((bitField0_ & 0x00000002) != 0),
                   getParentForChildren(),
@@ -22636,8 +22636,8 @@ public com.google.protobuf.DescriptorProtos.MethodDescriptorProto.Builder addMet
       }
 
       private com.google.protobuf.DescriptorProtos.ServiceOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ServiceOptions, com.google.protobuf.DescriptorProtos.ServiceOptions.Builder, com.google.protobuf.DescriptorProtos.ServiceOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                ServiceOptions, ServiceOptions.Builder, ServiceOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.ServiceOptions options = 3;
        * @return Whether the options field is set.
@@ -22742,12 +22742,12 @@ public com.google.protobuf.DescriptorProtos.ServiceOptionsOrBuilder getOptionsOr
       /**
        * optional .google.protobuf.ServiceOptions options = 3;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.ServiceOptions, com.google.protobuf.DescriptorProtos.ServiceOptions.Builder, com.google.protobuf.DescriptorProtos.ServiceOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                ServiceOptions, ServiceOptions.Builder, ServiceOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.ServiceOptions, com.google.protobuf.DescriptorProtos.ServiceOptions.Builder, com.google.protobuf.DescriptorProtos.ServiceOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        ServiceOptions, ServiceOptions.Builder, ServiceOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -22950,12 +22950,12 @@ public interface MethodDescriptorProtoOrBuilder extends
    * Protobuf type {@code google.protobuf.MethodDescriptorProto}
    */
   public static final class MethodDescriptorProto extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.MethodDescriptorProto)
       MethodDescriptorProtoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use MethodDescriptorProto.newBuilder() to construct.
-    private MethodDescriptorProto(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private MethodDescriptorProto(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private MethodDescriptorProto() {
@@ -22977,7 +22977,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MethodDescriptorProto_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -23248,13 +23248,13 @@ public final boolean isInitialized() {
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 2, inputType_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, inputType_);
       }
       if (((bitField0_ & 0x00000004) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 3, outputType_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, outputType_);
       }
       if (((bitField0_ & 0x00000008) != 0)) {
         output.writeMessage(4, getOptions());
@@ -23275,13 +23275,13 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, inputType_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, inputType_);
       }
       if (((bitField0_ & 0x00000004) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, outputType_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, outputType_);
       }
       if (((bitField0_ & 0x00000008) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -23416,20 +23416,20 @@ public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseFr
     }
     public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -23437,20 +23437,20 @@ public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseDe
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MethodDescriptorProto parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -23470,7 +23470,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -23482,7 +23482,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.MethodDescriptorProto}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.MethodDescriptorProto)
         com.google.protobuf.DescriptorProtos.MethodDescriptorProtoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -23491,7 +23491,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MethodDescriptorProto_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -23504,12 +23504,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getOptionsFieldBuilder();
         }
@@ -24010,8 +24010,8 @@ public Builder setOutputTypeBytes(
       }
 
       private com.google.protobuf.DescriptorProtos.MethodOptions options_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MethodOptions, com.google.protobuf.DescriptorProtos.MethodOptions.Builder, com.google.protobuf.DescriptorProtos.MethodOptionsOrBuilder> optionsBuilder_;
+      private SingleFieldBuilderV3Internal<
+                MethodOptions, MethodOptions.Builder, MethodOptionsOrBuilder> optionsBuilder_;
       /**
        * optional .google.protobuf.MethodOptions options = 4;
        * @return Whether the options field is set.
@@ -24116,12 +24116,12 @@ public com.google.protobuf.DescriptorProtos.MethodOptionsOrBuilder getOptionsOrB
       /**
        * optional .google.protobuf.MethodOptions options = 4;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.MethodOptions, com.google.protobuf.DescriptorProtos.MethodOptions.Builder, com.google.protobuf.DescriptorProtos.MethodOptionsOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                MethodOptions, MethodOptions.Builder, MethodOptionsOrBuilder>
           getOptionsFieldBuilder() {
         if (optionsBuilder_ == null) {
-          optionsBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.MethodOptions, com.google.protobuf.DescriptorProtos.MethodOptions.Builder, com.google.protobuf.DescriptorProtos.MethodOptionsOrBuilder>(
+          optionsBuilder_ = new SingleFieldBuilderV3Internal<
+                        MethodOptions, MethodOptions.Builder, MethodOptionsOrBuilder>(
                   getOptions(),
                   getParentForChildren(),
                   isClean());
@@ -24307,7 +24307,7 @@ public com.google.protobuf.DescriptorProtos.MethodDescriptorProto getDefaultInst
 
   public interface FileOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.FileOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -24960,13 +24960,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.FileOptions}
    */
   public static final class FileOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         FileOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FileOptions)
       FileOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FileOptions.newBuilder() to construct.
-    private FileOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private FileOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private FileOptions() {
@@ -24998,7 +24998,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -26234,14 +26234,14 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 1, javaPackage_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, javaPackage_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 8, javaOuterClassname_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 8, javaOuterClassname_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
         output.writeEnum(9, optimizeFor_);
@@ -26250,7 +26250,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeBool(10, javaMultipleFiles_);
       }
       if (((bitField0_ & 0x00000040) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 11, goPackage_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 11, goPackage_);
       }
       if (((bitField0_ & 0x00000080) != 0)) {
         output.writeBool(16, ccGenericServices_);
@@ -26274,25 +26274,25 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeBool(31, ccEnableArenas_);
       }
       if (((bitField0_ & 0x00001000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 36, objcClassPrefix_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 36, objcClassPrefix_);
       }
       if (((bitField0_ & 0x00002000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 37, csharpNamespace_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 37, csharpNamespace_);
       }
       if (((bitField0_ & 0x00004000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 39, swiftPrefix_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 39, swiftPrefix_);
       }
       if (((bitField0_ & 0x00008000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 40, phpClassPrefix_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 40, phpClassPrefix_);
       }
       if (((bitField0_ & 0x00010000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 41, phpNamespace_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 41, phpNamespace_);
       }
       if (((bitField0_ & 0x00020000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 44, phpMetadataNamespace_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 44, phpMetadataNamespace_);
       }
       if (((bitField0_ & 0x00040000) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 45, rubyPackage_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 45, rubyPackage_);
       }
       if (((bitField0_ & 0x00080000) != 0)) {
         output.writeMessage(50, getFeatures());
@@ -26311,10 +26311,10 @@ public int getSerializedSize() {
 
       size = 0;
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, javaPackage_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, javaPackage_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, javaOuterClassname_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(8, javaOuterClassname_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -26325,7 +26325,7 @@ public int getSerializedSize() {
           .computeBoolSize(10, javaMultipleFiles_);
       }
       if (((bitField0_ & 0x00000040) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, goPackage_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(11, goPackage_);
       }
       if (((bitField0_ & 0x00000080) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -26356,25 +26356,25 @@ public int getSerializedSize() {
           .computeBoolSize(31, ccEnableArenas_);
       }
       if (((bitField0_ & 0x00001000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(36, objcClassPrefix_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(36, objcClassPrefix_);
       }
       if (((bitField0_ & 0x00002000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(37, csharpNamespace_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(37, csharpNamespace_);
       }
       if (((bitField0_ & 0x00004000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(39, swiftPrefix_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(39, swiftPrefix_);
       }
       if (((bitField0_ & 0x00008000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(40, phpClassPrefix_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(40, phpClassPrefix_);
       }
       if (((bitField0_ & 0x00010000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(41, phpNamespace_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(41, phpNamespace_);
       }
       if (((bitField0_ & 0x00020000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(44, phpMetadataNamespace_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(44, phpMetadataNamespace_);
       }
       if (((bitField0_ & 0x00040000) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(45, rubyPackage_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(45, rubyPackage_);
       }
       if (((bitField0_ & 0x00080000) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -26646,20 +26646,20 @@ public static com.google.protobuf.DescriptorProtos.FileOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.FileOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FileOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -26667,20 +26667,20 @@ public static com.google.protobuf.DescriptorProtos.FileOptions parseDelimitedFro
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FileOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FileOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -26700,7 +26700,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -26708,7 +26708,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FileOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.FileOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FileOptions)
         com.google.protobuf.DescriptorProtos.FileOptionsOrBuilder {
@@ -26718,7 +26718,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FileOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -26731,12 +26731,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -26941,33 +26941,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FileOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FileOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.FileOptions) {
@@ -27079,7 +27079,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FileOptions other)
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00100000);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -29012,8 +29012,8 @@ public Builder setRubyPackageBytes(
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -29181,12 +29181,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 50;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -29204,8 +29204,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -29386,7 +29386,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -29510,12 +29510,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00100000) != 0),
                   getParentForChildren(),
@@ -29590,7 +29590,7 @@ public com.google.protobuf.DescriptorProtos.FileOptions getDefaultInstanceForTyp
 
   public interface MessageOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.MessageOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -29878,13 +29878,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.MessageOptions}
    */
   public static final class MessageOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         MessageOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.MessageOptions)
       MessageOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use MessageOptions.newBuilder() to construct.
-    private MessageOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private MessageOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private MessageOptions() {
@@ -29904,7 +29904,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MessageOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -30291,7 +30291,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -30487,20 +30487,20 @@ public static com.google.protobuf.DescriptorProtos.MessageOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.MessageOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MessageOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.MessageOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -30508,20 +30508,20 @@ public static com.google.protobuf.DescriptorProtos.MessageOptions parseDelimited
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.MessageOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MessageOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -30541,7 +30541,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -30549,7 +30549,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.MessageOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.MessageOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.MessageOptions)
         com.google.protobuf.DescriptorProtos.MessageOptionsOrBuilder {
@@ -30559,7 +30559,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MessageOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -30572,12 +30572,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -30712,33 +30712,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MessageOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MessageOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MessageOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MessageOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MessageOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MessageOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MessageOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MessageOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.MessageOptions) {
@@ -30788,7 +30788,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.MessageOptions oth
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000040);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -31390,8 +31390,8 @@ public Builder clearMapEntry() {
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -31559,12 +31559,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 12;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -31582,8 +31582,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -31754,7 +31754,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -31870,12 +31870,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000040) != 0),
                   getParentForChildren(),
@@ -31950,7 +31950,7 @@ public com.google.protobuf.DescriptorProtos.MessageOptions getDefaultInstanceFor
 
   public interface FieldOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.FieldOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -32354,13 +32354,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.FieldOptions}
    */
   public static final class FieldOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         FieldOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FieldOptions)
       FieldOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FieldOptions.newBuilder() to construct.
-    private FieldOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private FieldOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private FieldOptions() {
@@ -32385,7 +32385,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -32983,12 +32983,12 @@ public interface EditionDefaultOrBuilder extends
      * Protobuf type {@code google.protobuf.FieldOptions.EditionDefault}
      */
     public static final class EditionDefault extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.FieldOptions.EditionDefault)
         EditionDefaultOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use EditionDefault.newBuilder() to construct.
-      private EditionDefault(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private EditionDefault(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private EditionDefault() {
@@ -33009,7 +33009,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_EditionDefault_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -33111,7 +33111,7 @@ public final boolean isInitialized() {
       public void writeTo(com.google.protobuf.CodedOutputStream output)
                           throws java.io.IOException {
         if (((bitField0_ & 0x00000002) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 2, value_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, value_);
         }
         if (((bitField0_ & 0x00000001) != 0)) {
           output.writeEnum(3, edition_);
@@ -33126,7 +33126,7 @@ public int getSerializedSize() {
 
         size = 0;
         if (((bitField0_ & 0x00000002) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, value_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, value_);
         }
         if (((bitField0_ & 0x00000001) != 0)) {
           size += com.google.protobuf.CodedOutputStream
@@ -33214,20 +33214,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault p
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -33235,20 +33235,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault p
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -33268,7 +33268,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -33276,7 +33276,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.FieldOptions.EditionDefault}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.FieldOptions.EditionDefault)
           com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefaultOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -33285,7 +33285,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_EditionDefault_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -33298,7 +33298,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -33785,12 +33785,12 @@ public interface FeatureSupportOrBuilder extends
      * Protobuf type {@code google.protobuf.FieldOptions.FeatureSupport}
      */
     public static final class FeatureSupport extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.FieldOptions.FeatureSupport)
         FeatureSupportOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use FeatureSupport.newBuilder() to construct.
-      private FeatureSupport(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private FeatureSupport(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private FeatureSupport() {
@@ -33813,7 +33813,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_FeatureSupport_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -33994,7 +33994,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
           output.writeEnum(2, editionDeprecated_);
         }
         if (((bitField0_ & 0x00000004) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 3, deprecationWarning_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, deprecationWarning_);
         }
         if (((bitField0_ & 0x00000008) != 0)) {
           output.writeEnum(4, editionRemoved_);
@@ -34017,7 +34017,7 @@ public int getSerializedSize() {
             .computeEnumSize(2, editionDeprecated_);
         }
         if (((bitField0_ & 0x00000004) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, deprecationWarning_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, deprecationWarning_);
         }
         if (((bitField0_ & 0x00000008) != 0)) {
           size += com.google.protobuf.CodedOutputStream
@@ -34121,20 +34121,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport p
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -34142,20 +34142,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport p
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -34175,7 +34175,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -34187,7 +34187,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.FieldOptions.FeatureSupport}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.FieldOptions.FeatureSupport)
           com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -34196,7 +34196,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_FeatureSupport_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -34209,7 +34209,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -35358,7 +35358,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -35662,20 +35662,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.FieldOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FieldOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FieldOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -35683,20 +35683,20 @@ public static com.google.protobuf.DescriptorProtos.FieldOptions parseDelimitedFr
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FieldOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FieldOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -35716,7 +35716,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -35724,7 +35724,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FieldOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.FieldOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FieldOptions)
         com.google.protobuf.DescriptorProtos.FieldOptionsOrBuilder {
@@ -35734,7 +35734,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FieldOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -35747,12 +35747,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getEditionDefaultsFieldBuilder();
           getFeaturesFieldBuilder();
@@ -35943,33 +35943,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FieldOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FieldOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FieldOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FieldOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FieldOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FieldOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FieldOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FieldOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.FieldOptions) {
@@ -36038,7 +36038,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FieldOptions other
               editionDefaults_ = other.editionDefaults_;
               bitField0_ = (bitField0_ & ~0x00000400);
               editionDefaultsBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getEditionDefaultsFieldBuilder() : null;
             } else {
               editionDefaultsBuilder_.addAllMessages(other.editionDefaults_);
@@ -36070,7 +36070,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FieldOptions other
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00002000);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -37054,8 +37054,8 @@ private void ensureEditionDefaultsIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefaultOrBuilder> editionDefaultsBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                EditionDefault, EditionDefault.Builder, EditionDefaultOrBuilder> editionDefaultsBuilder_;
 
       /**
        * repeated .google.protobuf.FieldOptions.EditionDefault edition_defaults = 20;
@@ -37186,7 +37186,7 @@ public Builder addAllEditionDefaults(
           java.lang.Iterable values) {
         if (editionDefaultsBuilder_ == null) {
           ensureEditionDefaultsIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, editionDefaults_);
           onChanged();
         } else {
@@ -37270,12 +37270,12 @@ public com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault.Builder
            getEditionDefaultsBuilderList() {
         return getEditionDefaultsFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefaultOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                EditionDefault, EditionDefault.Builder, EditionDefaultOrBuilder>
           getEditionDefaultsFieldBuilder() {
         if (editionDefaultsBuilder_ == null) {
-          editionDefaultsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefaultOrBuilder>(
+          editionDefaultsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        EditionDefault, EditionDefault.Builder, EditionDefaultOrBuilder>(
                   editionDefaults_,
                   ((bitField0_ & 0x00000400) != 0),
                   getParentForChildren(),
@@ -37286,8 +37286,8 @@ public com.google.protobuf.DescriptorProtos.FieldOptions.EditionDefault.Builder
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -37455,12 +37455,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 21;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -37470,8 +37470,8 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
       }
 
       private com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport featureSupport_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder> featureSupportBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSupport, FeatureSupport.Builder, FeatureSupportOrBuilder> featureSupportBuilder_;
       /**
        * optional .google.protobuf.FieldOptions.FeatureSupport feature_support = 22;
        * @return Whether the featureSupport field is set.
@@ -37576,12 +37576,12 @@ public com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder
       /**
        * optional .google.protobuf.FieldOptions.FeatureSupport feature_support = 22;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSupport, FeatureSupport.Builder, FeatureSupportOrBuilder>
           getFeatureSupportFieldBuilder() {
         if (featureSupportBuilder_ == null) {
-          featureSupportBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder>(
+          featureSupportBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSupport, FeatureSupport.Builder, FeatureSupportOrBuilder>(
                   getFeatureSupport(),
                   getParentForChildren(),
                   isClean());
@@ -37599,8 +37599,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -37771,7 +37771,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -37887,12 +37887,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00002000) != 0),
                   getParentForChildren(),
@@ -37967,7 +37967,7 @@ public com.google.protobuf.DescriptorProtos.FieldOptions getDefaultInstanceForTy
 
   public interface OneofOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.OneofOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -38054,13 +38054,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.OneofOptions}
    */
   public static final class OneofOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         OneofOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.OneofOptions)
       OneofOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use OneofOptions.newBuilder() to construct.
-    private OneofOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private OneofOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private OneofOptions() {
@@ -38080,7 +38080,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_OneofOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -38226,7 +38226,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -38337,20 +38337,20 @@ public static com.google.protobuf.DescriptorProtos.OneofOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.OneofOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.OneofOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.OneofOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -38358,20 +38358,20 @@ public static com.google.protobuf.DescriptorProtos.OneofOptions parseDelimitedFr
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.OneofOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.OneofOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -38391,7 +38391,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -38399,7 +38399,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.OneofOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.OneofOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.OneofOptions)
         com.google.protobuf.DescriptorProtos.OneofOptionsOrBuilder {
@@ -38409,7 +38409,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_OneofOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -38422,12 +38422,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -38537,33 +38537,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.OneofOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.OneofOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.OneofOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.OneofOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.OneofOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.OneofOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.OneofOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.OneofOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.OneofOptions) {
@@ -38598,7 +38598,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.OneofOptions other
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000002);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -38683,8 +38683,8 @@ public Builder mergeFrom(
       private int bitField0_;
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -38852,12 +38852,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 1;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -38875,8 +38875,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -39047,7 +39047,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -39163,12 +39163,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000002) != 0),
                   getParentForChildren(),
@@ -39243,7 +39243,7 @@ public com.google.protobuf.DescriptorProtos.OneofOptions getDefaultInstanceForTy
 
   public interface EnumOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.EnumOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -39409,13 +39409,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.EnumOptions}
    */
   public static final class EnumOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         EnumOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.EnumOptions)
       EnumOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use EnumOptions.newBuilder() to construct.
-    private EnumOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private EnumOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private EnumOptions() {
@@ -39435,7 +39435,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -39684,7 +39684,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -39846,20 +39846,20 @@ public static com.google.protobuf.DescriptorProtos.EnumOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.EnumOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.EnumOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -39867,20 +39867,20 @@ public static com.google.protobuf.DescriptorProtos.EnumOptions parseDelimitedFro
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.EnumOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -39900,7 +39900,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -39908,7 +39908,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.EnumOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.EnumOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.EnumOptions)
         com.google.protobuf.DescriptorProtos.EnumOptionsOrBuilder {
@@ -39918,7 +39918,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -39931,12 +39931,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -40061,33 +40061,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.EnumOptions) {
@@ -40131,7 +40131,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.EnumOptions other)
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000010);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -40443,8 +40443,8 @@ public Builder clearDeprecated() {
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -40612,12 +40612,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 7;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -40635,8 +40635,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -40807,7 +40807,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -40923,12 +40923,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000010) != 0),
                   getParentForChildren(),
@@ -41003,7 +41003,7 @@ public com.google.protobuf.DescriptorProtos.EnumOptions getDefaultInstanceForTyp
 
   public interface EnumValueOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.EnumValueOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -41165,13 +41165,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.EnumValueOptions}
    */
   public static final class EnumValueOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         EnumValueOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.EnumValueOptions)
       EnumValueOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use EnumValueOptions.newBuilder() to construct.
-    private EnumValueOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private EnumValueOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private EnumValueOptions() {
@@ -41191,7 +41191,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumValueOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -41439,7 +41439,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -41600,20 +41600,20 @@ public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -41621,20 +41621,20 @@ public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseDelimit
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.EnumValueOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -41654,7 +41654,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -41662,7 +41662,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.EnumValueOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.EnumValueOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.EnumValueOptions)
         com.google.protobuf.DescriptorProtos.EnumValueOptionsOrBuilder {
@@ -41672,7 +41672,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_EnumValueOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -41685,12 +41685,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getFeatureSupportFieldBuilder();
@@ -41822,33 +41822,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumValueOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumValueOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumValueOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.EnumValueOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumValueOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumValueOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumValueOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.EnumValueOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.EnumValueOptions) {
@@ -41892,7 +41892,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.EnumValueOptions o
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000010);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -42062,8 +42062,8 @@ public Builder clearDeprecated() {
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -42231,12 +42231,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 2;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -42310,8 +42310,8 @@ public Builder clearDebugRedact() {
       }
 
       private com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport featureSupport_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder> featureSupportBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FieldOptions.FeatureSupport, FieldOptions.FeatureSupport.Builder, FieldOptions.FeatureSupportOrBuilder> featureSupportBuilder_;
       /**
        * 
        * Information about the support window of a feature value.
@@ -42452,12 +42452,12 @@ public com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder
        *
        * optional .google.protobuf.FieldOptions.FeatureSupport feature_support = 4;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FieldOptions.FeatureSupport, FieldOptions.FeatureSupport.Builder, FieldOptions.FeatureSupportOrBuilder>
           getFeatureSupportFieldBuilder() {
         if (featureSupportBuilder_ == null) {
-          featureSupportBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupport.Builder, com.google.protobuf.DescriptorProtos.FieldOptions.FeatureSupportOrBuilder>(
+          featureSupportBuilder_ = new SingleFieldBuilderV3Internal<
+                        FieldOptions.FeatureSupport, FieldOptions.FeatureSupport.Builder, FieldOptions.FeatureSupportOrBuilder>(
                   getFeatureSupport(),
                   getParentForChildren(),
                   isClean());
@@ -42475,8 +42475,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -42647,7 +42647,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -42763,12 +42763,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000010) != 0),
                   getParentForChildren(),
@@ -42843,7 +42843,7 @@ public com.google.protobuf.DescriptorProtos.EnumValueOptions getDefaultInstanceF
 
   public interface ServiceOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.ServiceOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -42955,13 +42955,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.ServiceOptions}
    */
   public static final class ServiceOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         ServiceOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.ServiceOptions)
       ServiceOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use ServiceOptions.newBuilder() to construct.
-    private ServiceOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private ServiceOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private ServiceOptions() {
@@ -42981,7 +42981,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ServiceOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -43160,7 +43160,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000002) != 0)) {
@@ -43288,20 +43288,20 @@ public static com.google.protobuf.DescriptorProtos.ServiceOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.ServiceOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.ServiceOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -43309,20 +43309,20 @@ public static com.google.protobuf.DescriptorProtos.ServiceOptions parseDelimited
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.ServiceOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -43342,7 +43342,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -43350,7 +43350,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.ServiceOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.ServiceOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.ServiceOptions)
         com.google.protobuf.DescriptorProtos.ServiceOptionsOrBuilder {
@@ -43360,7 +43360,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_ServiceOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -43373,12 +43373,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -43493,33 +43493,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ServiceOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ServiceOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ServiceOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.ServiceOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ServiceOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ServiceOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ServiceOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.ServiceOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.ServiceOptions) {
@@ -43557,7 +43557,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.ServiceOptions oth
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000004);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -43647,8 +43647,8 @@ public Builder mergeFrom(
       private int bitField0_;
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -43816,12 +43816,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 34;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -43907,8 +43907,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -44079,7 +44079,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -44195,12 +44195,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000004) != 0),
                   getParentForChildren(),
@@ -44275,7 +44275,7 @@ public com.google.protobuf.DescriptorProtos.ServiceOptions getDefaultInstanceFor
 
   public interface MethodOptionsOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.MethodOptions)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -44398,13 +44398,13 @@ com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder getUninterpret
    * Protobuf type {@code google.protobuf.MethodOptions}
    */
   public static final class MethodOptions extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         MethodOptions> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.MethodOptions)
       MethodOptionsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use MethodOptions.newBuilder() to construct.
-    private MethodOptions(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private MethodOptions(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private MethodOptions() {
@@ -44425,7 +44425,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MethodOptions_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -44749,7 +44749,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -44892,20 +44892,20 @@ public static com.google.protobuf.DescriptorProtos.MethodOptions parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.MethodOptions parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MethodOptions parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.MethodOptions parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -44913,20 +44913,20 @@ public static com.google.protobuf.DescriptorProtos.MethodOptions parseDelimitedF
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.MethodOptions parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.MethodOptions parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -44946,7 +44946,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -44954,7 +44954,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.MethodOptions}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.MethodOptions, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.MethodOptions)
         com.google.protobuf.DescriptorProtos.MethodOptionsOrBuilder {
@@ -44964,7 +44964,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_MethodOptions_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -44977,12 +44977,12 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
         maybeForceBuilderInitialization();
       }
       private void maybeForceBuilderInitialization() {
-        if (com.google.protobuf.GeneratedMessageV3
+        if (com.google.protobuf.GeneratedMessageV3Internal
                 .alwaysUseFieldBuilders) {
           getFeaturesFieldBuilder();
           getUninterpretedOptionFieldBuilder();
@@ -45102,33 +45102,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MethodOptions, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MethodOptions, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MethodOptions, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.MethodOptions, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MethodOptions, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MethodOptions, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MethodOptions, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.MethodOptions, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.MethodOptions) {
@@ -45169,7 +45169,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.MethodOptions othe
               uninterpretedOption_ = other.uninterpretedOption_;
               bitField0_ = (bitField0_ & ~0x00000008);
               uninterpretedOptionBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getUninterpretedOptionFieldBuilder() : null;
             } else {
               uninterpretedOptionBuilder_.addAllMessages(other.uninterpretedOption_);
@@ -45381,8 +45381,8 @@ public Builder clearIdempotencyLevel() {
       }
 
       private com.google.protobuf.DescriptorProtos.FeatureSet features_;
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> featuresBuilder_;
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> featuresBuilder_;
       /**
        * 
        * Any features defined in the specific edition.
@@ -45550,12 +45550,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFeaturesOrBui
        *
        * optional .google.protobuf.FeatureSet features = 35;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+      private SingleFieldBuilderV3Internal<
+                FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
           getFeaturesFieldBuilder() {
         if (featuresBuilder_ == null) {
-          featuresBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+          featuresBuilder_ = new SingleFieldBuilderV3Internal<
+                        FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                   getFeatures(),
                   getParentForChildren(),
                   isClean());
@@ -45573,8 +45573,8 @@ private void ensureUninterpretedOptionIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder> uninterpretedOptionBuilder_;
 
       /**
        * 
@@ -45745,7 +45745,7 @@ public Builder addAllUninterpretedOption(
           java.lang.Iterable values) {
         if (uninterpretedOptionBuilder_ == null) {
           ensureUninterpretedOptionIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, uninterpretedOption_);
           onChanged();
         } else {
@@ -45861,12 +45861,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder addUnint
            getUninterpretedOptionBuilderList() {
         return getUninterpretedOptionFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>
           getUninterpretedOptionFieldBuilder() {
         if (uninterpretedOptionBuilder_ == null) {
-          uninterpretedOptionBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption, com.google.protobuf.DescriptorProtos.UninterpretedOption.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder>(
+          uninterpretedOptionBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        UninterpretedOption, UninterpretedOption.Builder, UninterpretedOptionOrBuilder>(
                   uninterpretedOption_,
                   ((bitField0_ & 0x00000008) != 0),
                   getParentForChildren(),
@@ -46073,12 +46073,12 @@ com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePartOrBuilder getNa
    * Protobuf type {@code google.protobuf.UninterpretedOption}
    */
   public static final class UninterpretedOption extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.UninterpretedOption)
       UninterpretedOptionOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use UninterpretedOption.newBuilder() to construct.
-    private UninterpretedOption(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private UninterpretedOption(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private UninterpretedOption() {
@@ -46101,7 +46101,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_UninterpretedOption_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -46152,12 +46152,12 @@ public interface NamePartOrBuilder extends
      * Protobuf type {@code google.protobuf.UninterpretedOption.NamePart}
      */
     public static final class NamePart extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.UninterpretedOption.NamePart)
         NamePartOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use NamePart.newBuilder() to construct.
-      private NamePart(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private NamePart(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private NamePart() {
@@ -46177,7 +46177,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_UninterpretedOption_NamePart_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -46276,7 +46276,7 @@ public final boolean isInitialized() {
       public void writeTo(com.google.protobuf.CodedOutputStream output)
                           throws java.io.IOException {
         if (((bitField0_ & 0x00000001) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 1, namePart_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, namePart_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
           output.writeBool(2, isExtension_);
@@ -46291,7 +46291,7 @@ public int getSerializedSize() {
 
         size = 0;
         if (((bitField0_ & 0x00000001) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, namePart_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, namePart_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
           size += com.google.protobuf.CodedOutputStream
@@ -46381,20 +46381,20 @@ public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart
       }
       public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -46402,20 +46402,20 @@ public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -46435,7 +46435,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -46451,7 +46451,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.UninterpretedOption.NamePart}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.UninterpretedOption.NamePart)
           com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePartOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -46460,7 +46460,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_UninterpretedOption_NamePart_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -46473,7 +46473,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -47077,7 +47077,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeMessage(2, name_.get(i));
       }
       if (((bitField0_ & 0x00000001) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 3, identifierValue_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, identifierValue_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         output.writeUInt64(4, positiveIntValue_);
@@ -47092,7 +47092,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
         output.writeBytes(7, stringValue_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
-        com.google.protobuf.GeneratedMessageV3.writeString(output, 8, aggregateValue_);
+        com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 8, aggregateValue_);
       }
       getUnknownFields().writeTo(output);
     }
@@ -47108,7 +47108,7 @@ public int getSerializedSize() {
           .computeMessageSize(2, name_.get(i));
       }
       if (((bitField0_ & 0x00000001) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, identifierValue_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, identifierValue_);
       }
       if (((bitField0_ & 0x00000002) != 0)) {
         size += com.google.protobuf.CodedOutputStream
@@ -47127,7 +47127,7 @@ public int getSerializedSize() {
           .computeBytesSize(7, stringValue_);
       }
       if (((bitField0_ & 0x00000020) != 0)) {
-        size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, aggregateValue_);
+        size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(8, aggregateValue_);
       }
       size += getUnknownFields().getSerializedSize();
       memoizedSize = size;
@@ -47258,20 +47258,20 @@ public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseFrom
     }
     public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -47279,20 +47279,20 @@ public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseDeli
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.UninterpretedOption parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -47312,7 +47312,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -47329,7 +47329,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.UninterpretedOption}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.UninterpretedOption)
         com.google.protobuf.DescriptorProtos.UninterpretedOptionOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -47338,7 +47338,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_UninterpretedOption_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -47351,7 +47351,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -47509,7 +47509,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.UninterpretedOptio
               name_ = other.name_;
               bitField0_ = (bitField0_ & ~0x00000001);
               nameBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getNameFieldBuilder() : null;
             } else {
               nameBuilder_.addAllMessages(other.name_);
@@ -47638,8 +47638,8 @@ private void ensureNameIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePartOrBuilder> nameBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                NamePart, NamePart.Builder, NamePartOrBuilder> nameBuilder_;
 
       /**
        * repeated .google.protobuf.UninterpretedOption.NamePart name = 2;
@@ -47770,7 +47770,7 @@ public Builder addAllName(
           java.lang.Iterable values) {
         if (nameBuilder_ == null) {
           ensureNameIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, name_);
           onChanged();
         } else {
@@ -47854,12 +47854,12 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart.Builder
            getNameBuilderList() {
         return getNameFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePartOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                NamePart, NamePart.Builder, NamePartOrBuilder>
           getNameFieldBuilder() {
         if (nameBuilder_ == null) {
-          nameBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePart.Builder, com.google.protobuf.DescriptorProtos.UninterpretedOption.NamePartOrBuilder>(
+          nameBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        NamePart, NamePart.Builder, NamePartOrBuilder>(
                   name_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -48284,7 +48284,7 @@ public com.google.protobuf.DescriptorProtos.UninterpretedOption getDefaultInstan
 
   public interface FeatureSetOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.FeatureSet)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -48366,13 +48366,13 @@ public interface FeatureSetOrBuilder extends
    * Protobuf type {@code google.protobuf.FeatureSet}
    */
   public static final class FeatureSet extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         FeatureSet> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FeatureSet)
       FeatureSetOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FeatureSet.newBuilder() to construct.
-    private FeatureSet(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private FeatureSet(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private FeatureSet() {
@@ -48397,7 +48397,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSet_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -49170,7 +49170,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       if (((bitField0_ & 0x00000001) != 0)) {
@@ -49342,20 +49342,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSet parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSet parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSet parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FeatureSet parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -49363,20 +49363,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSet parseDelimitedFrom
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSet parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSet parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -49396,7 +49396,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -49413,7 +49413,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FeatureSet}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.FeatureSet, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FeatureSet)
         com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder {
@@ -49423,7 +49423,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSet_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -49436,7 +49436,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -49543,33 +49543,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FeatureSet, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FeatureSet, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FeatureSet, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.FeatureSet, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FeatureSet, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FeatureSet, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FeatureSet, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.FeatureSet, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.FeatureSet) {
@@ -50115,12 +50115,12 @@ com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault
    * Protobuf type {@code google.protobuf.FeatureSetDefaults}
    */
   public static final class FeatureSetDefaults extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.FeatureSetDefaults)
       FeatureSetDefaultsOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use FeatureSetDefaults.newBuilder() to construct.
-    private FeatureSetDefaults(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private FeatureSetDefaults(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private FeatureSetDefaults() {
@@ -50142,7 +50142,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSetDefaults_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -50229,12 +50229,12 @@ public interface FeatureSetEditionDefaultOrBuilder extends
      * Protobuf type {@code google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault}
      */
     public static final class FeatureSetEditionDefault extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault)
         FeatureSetEditionDefaultOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use FeatureSetEditionDefault.newBuilder() to construct.
-      private FeatureSetEditionDefault(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private FeatureSetEditionDefault(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private FeatureSetEditionDefault() {
@@ -50254,7 +50254,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -50503,20 +50503,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSet
       }
       public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -50524,20 +50524,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSet
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -50557,7 +50557,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -50572,7 +50572,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault)
           com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefaultOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -50581,7 +50581,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -50594,12 +50594,12 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
           maybeForceBuilderInitialization();
         }
         private void maybeForceBuilderInitialization() {
-          if (com.google.protobuf.GeneratedMessageV3
+          if (com.google.protobuf.GeneratedMessageV3Internal
                   .alwaysUseFieldBuilders) {
             getOverridableFeaturesFieldBuilder();
             getFixedFeaturesFieldBuilder();
@@ -50848,8 +50848,8 @@ public Builder clearEdition() {
         }
 
         private com.google.protobuf.DescriptorProtos.FeatureSet overridableFeatures_;
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> overridableFeaturesBuilder_;
+        private SingleFieldBuilderV3Internal<
+                    FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> overridableFeaturesBuilder_;
         /**
          * 
          * Defaults of features that can be overridden in this edition.
@@ -50990,12 +50990,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getOverridableFe
          *
          * optional .google.protobuf.FeatureSet overridable_features = 4;
          */
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+        private SingleFieldBuilderV3Internal<
+                    FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
             getOverridableFeaturesFieldBuilder() {
           if (overridableFeaturesBuilder_ == null) {
-            overridableFeaturesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-                com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+            overridableFeaturesBuilder_ = new SingleFieldBuilderV3Internal<
+                            FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                     getOverridableFeatures(),
                     getParentForChildren(),
                     isClean());
@@ -51005,8 +51005,8 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getOverridableFe
         }
 
         private com.google.protobuf.DescriptorProtos.FeatureSet fixedFeatures_;
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> fixedFeaturesBuilder_;
+        private SingleFieldBuilderV3Internal<
+                    FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder> fixedFeaturesBuilder_;
         /**
          * 
          * Defaults of features that can't be overridden in this edition.
@@ -51147,12 +51147,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder getFixedFeatures
          *
          * optional .google.protobuf.FeatureSet fixed_features = 5;
          */
-        private com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder> 
+        private SingleFieldBuilderV3Internal<
+                    FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>
             getFixedFeaturesFieldBuilder() {
           if (fixedFeaturesBuilder_ == null) {
-            fixedFeaturesBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-                com.google.protobuf.DescriptorProtos.FeatureSet, com.google.protobuf.DescriptorProtos.FeatureSet.Builder, com.google.protobuf.DescriptorProtos.FeatureSetOrBuilder>(
+            fixedFeaturesBuilder_ = new SingleFieldBuilderV3Internal<
+                            FeatureSet, FeatureSet.Builder, FeatureSetOrBuilder>(
                     getFixedFeatures(),
                     getParentForChildren(),
                     isClean());
@@ -51459,20 +51459,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -51480,20 +51480,20 @@ public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseDelim
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.FeatureSetDefaults parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -51513,7 +51513,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -51528,7 +51528,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.FeatureSetDefaults}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.FeatureSetDefaults)
         com.google.protobuf.DescriptorProtos.FeatureSetDefaultsOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -51537,7 +51537,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_FeatureSetDefaults_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -51550,7 +51550,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -51688,7 +51688,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.FeatureSetDefaults
               defaults_ = other.defaults_;
               bitField0_ = (bitField0_ & ~0x00000001);
               defaultsBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getDefaultsFieldBuilder() : null;
             } else {
               defaultsBuilder_.addAllMessages(other.defaults_);
@@ -51795,8 +51795,8 @@ private void ensureDefaultsIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault.Builder, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefaultOrBuilder> defaultsBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                FeatureSetEditionDefault, FeatureSetEditionDefault.Builder, FeatureSetEditionDefaultOrBuilder> defaultsBuilder_;
 
       /**
        * repeated .google.protobuf.FeatureSetDefaults.FeatureSetEditionDefault defaults = 1;
@@ -51927,7 +51927,7 @@ public Builder addAllDefaults(
           java.lang.Iterable values) {
         if (defaultsBuilder_ == null) {
           ensureDefaultsIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, defaults_);
           onChanged();
         } else {
@@ -52011,12 +52011,12 @@ public com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEdition
            getDefaultsBuilderList() {
         return getDefaultsFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault.Builder, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefaultOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                FeatureSetEditionDefault, FeatureSetEditionDefault.Builder, FeatureSetEditionDefaultOrBuilder>
           getDefaultsFieldBuilder() {
         if (defaultsBuilder_ == null) {
-          defaultsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefault.Builder, com.google.protobuf.DescriptorProtos.FeatureSetDefaults.FeatureSetEditionDefaultOrBuilder>(
+          defaultsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        FeatureSetEditionDefault, FeatureSetEditionDefault.Builder, FeatureSetEditionDefaultOrBuilder>(
                   defaults_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -52215,7 +52215,7 @@ public com.google.protobuf.DescriptorProtos.FeatureSetDefaults getDefaultInstanc
 
   public interface SourceCodeInfoOrBuilder extends
       // @@protoc_insertion_point(interface_extends:google.protobuf.SourceCodeInfo)
-      com.google.protobuf.GeneratedMessageV3.
+      com.google.protobuf.GeneratedMessageV3Internal.
           ExtendableMessageOrBuilder {
 
     /**
@@ -52481,13 +52481,13 @@ com.google.protobuf.DescriptorProtos.SourceCodeInfo.LocationOrBuilder getLocatio
    * Protobuf type {@code google.protobuf.SourceCodeInfo}
    */
   public static final class SourceCodeInfo extends
-      com.google.protobuf.GeneratedMessageV3.ExtendableMessage<
+      com.google.protobuf.GeneratedMessageV3Internal.ExtendableMessage<
         SourceCodeInfo> implements
       // @@protoc_insertion_point(message_implements:google.protobuf.SourceCodeInfo)
       SourceCodeInfoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use SourceCodeInfo.newBuilder() to construct.
-    private SourceCodeInfo(com.google.protobuf.GeneratedMessageV3.ExtendableBuilder builder) {
+    private SourceCodeInfo(com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder builder) {
       super(builder);
     }
     private SourceCodeInfo() {
@@ -52507,7 +52507,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_SourceCodeInfo_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -52867,12 +52867,12 @@ public interface LocationOrBuilder extends
      * Protobuf type {@code google.protobuf.SourceCodeInfo.Location}
      */
     public static final class Location extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.SourceCodeInfo.Location)
         LocationOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use Location.newBuilder() to construct.
-      private Location(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private Location(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private Location() {
@@ -52897,7 +52897,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_SourceCodeInfo_Location_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -53382,13 +53382,13 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
           output.writeInt32NoTag(span_.getInt(i));
         }
         if (((bitField0_ & 0x00000001) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 3, leadingComments_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, leadingComments_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 4, trailingComments_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 4, trailingComments_);
         }
         for (int i = 0; i < leadingDetachedComments_.size(); i++) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 6, leadingDetachedComments_.getRaw(i));
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 6, leadingDetachedComments_.getRaw(i));
         }
         getUnknownFields().writeTo(output);
       }
@@ -53428,10 +53428,10 @@ public int getSerializedSize() {
           spanMemoizedSerializedSize = dataSize;
         }
         if (((bitField0_ & 0x00000001) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, leadingComments_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, leadingComments_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, trailingComments_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(4, trailingComments_);
         }
         {
           int dataSize = 0;
@@ -53542,20 +53542,20 @@ public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parse
       }
       public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -53563,20 +53563,20 @@ public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parse
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -53596,7 +53596,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -53604,7 +53604,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.SourceCodeInfo.Location}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.SourceCodeInfo.Location)
           com.google.protobuf.DescriptorProtos.SourceCodeInfo.LocationOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -53613,7 +53613,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_SourceCodeInfo_Location_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -53626,7 +53626,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -54097,7 +54097,7 @@ public Builder addPath(int value) {
         public Builder addAllPath(
             java.lang.Iterable values) {
           ensurePathIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, path_);
           bitField0_ |= 0x00000001;
           onChanged();
@@ -54255,7 +54255,7 @@ public Builder addSpan(int value) {
         public Builder addAllSpan(
             java.lang.Iterable values) {
           ensureSpanIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, span_);
           bitField0_ |= 0x00000002;
           onChanged();
@@ -54818,7 +54818,7 @@ public Builder addLeadingDetachedComments(
         public Builder addAllLeadingDetachedComments(
             java.lang.Iterable values) {
           ensureLeadingDetachedCommentsIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, leadingDetachedComments_);
           bitField0_ |= 0x00000010;
           onChanged();
@@ -55202,7 +55202,7 @@ public final boolean isInitialized() {
     @java.lang.Override
     public void writeTo(com.google.protobuf.CodedOutputStream output)
                         throws java.io.IOException {
-      com.google.protobuf.GeneratedMessageV3
+      com.google.protobuf.GeneratedMessageV3Internal
         .ExtendableMessage.ExtensionWriter
           extensionWriter = newExtensionWriter();
       for (int i = 0; i < location_.size(); i++) {
@@ -55297,20 +55297,20 @@ public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -55318,20 +55318,20 @@ public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseDelimited
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.SourceCodeInfo parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -55351,7 +55351,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -55364,7 +55364,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.SourceCodeInfo}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<
+        com.google.protobuf.GeneratedMessageV3Internal.ExtendableBuilder<
           com.google.protobuf.DescriptorProtos.SourceCodeInfo, Builder> implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.SourceCodeInfo)
         com.google.protobuf.DescriptorProtos.SourceCodeInfoOrBuilder {
@@ -55374,7 +55374,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_SourceCodeInfo_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -55387,7 +55387,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -55482,33 +55482,33 @@ public Builder addRepeatedField(
           java.lang.Object value) {
         return super.addRepeatedField(field, value);
       }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo, Type> extension,
-          Type value) {
-        return super.setExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder setExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo, java.util.List> extension,
-          int index, Type value) {
-        return super.setExtension(extension, index, value);
-      }
-      @java.lang.Override
-      public  Builder addExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo, java.util.List> extension,
-          Type value) {
-        return super.addExtension(extension, value);
-      }
-      @java.lang.Override
-      public  Builder clearExtension(
-          com.google.protobuf.GeneratedMessage.GeneratedExtension<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo, T> extension) {
-        return super.clearExtension(extension);
-      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.SourceCodeInfo, Type> extension,
+//          Type value) {
+//        return super.setExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder setExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.SourceCodeInfo, java.util.List> extension,
+//          int index, Type value) {
+//        return super.setExtension(extension, index, value);
+//      }
+//      @java.lang.Override
+//      public  Builder addExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.SourceCodeInfo, java.util.List> extension,
+//          Type value) {
+//        return super.addExtension(extension, value);
+//      }
+//      @java.lang.Override
+//      public  Builder clearExtension(
+//          com.google.protobuf.GeneratedMessage.GeneratedExtension<
+//              com.google.protobuf.DescriptorProtos.SourceCodeInfo, T> extension) {
+//        return super.clearExtension(extension);
+//      }
       @java.lang.Override
       public Builder mergeFrom(com.google.protobuf.Message other) {
         if (other instanceof com.google.protobuf.DescriptorProtos.SourceCodeInfo) {
@@ -55540,7 +55540,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.SourceCodeInfo oth
               location_ = other.location_;
               bitField0_ = (bitField0_ & ~0x00000001);
               locationBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getLocationFieldBuilder() : null;
             } else {
               locationBuilder_.addAllMessages(other.location_);
@@ -55616,8 +55616,8 @@ private void ensureLocationIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfo.LocationOrBuilder> locationBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                Location, Location.Builder, LocationOrBuilder> locationBuilder_;
 
       /**
        * 
@@ -56208,7 +56208,7 @@ public Builder addAllLocation(
           java.lang.Iterable values) {
         if (locationBuilder_ == null) {
           ensureLocationIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, location_);
           onChanged();
         } else {
@@ -56660,12 +56660,12 @@ public com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location.Builder addL
            getLocationBuilderList() {
         return getLocationFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfo.LocationOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                Location, Location.Builder, LocationOrBuilder>
           getLocationFieldBuilder() {
         if (locationBuilder_ == null) {
-          locationBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location, com.google.protobuf.DescriptorProtos.SourceCodeInfo.Location.Builder, com.google.protobuf.DescriptorProtos.SourceCodeInfo.LocationOrBuilder>(
+          locationBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        Location, Location.Builder, LocationOrBuilder>(
                   location_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -56801,12 +56801,12 @@ com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.AnnotationOrBuilder getAn
    * Protobuf type {@code google.protobuf.GeneratedCodeInfo}
    */
   public static final class GeneratedCodeInfo extends
-      com.google.protobuf.GeneratedMessageV3 implements
+      com.google.protobuf.GeneratedMessageV3Internal implements
       // @@protoc_insertion_point(message_implements:google.protobuf.GeneratedCodeInfo)
       GeneratedCodeInfoOrBuilder {
   private static final long serialVersionUID = 0L;
     // Use GeneratedCodeInfo.newBuilder() to construct.
-    private GeneratedCodeInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+    private GeneratedCodeInfo(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
       super(builder);
     }
     private GeneratedCodeInfo() {
@@ -56826,7 +56826,7 @@ protected java.lang.Object newInstance(
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_GeneratedCodeInfo_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -56957,12 +56957,12 @@ public interface AnnotationOrBuilder extends
      * Protobuf type {@code google.protobuf.GeneratedCodeInfo.Annotation}
      */
     public static final class Annotation extends
-        com.google.protobuf.GeneratedMessageV3 implements
+        com.google.protobuf.GeneratedMessageV3Internal implements
         // @@protoc_insertion_point(message_implements:google.protobuf.GeneratedCodeInfo.Annotation)
         AnnotationOrBuilder {
     private static final long serialVersionUID = 0L;
       // Use Annotation.newBuilder() to construct.
-      private Annotation(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+      private Annotation(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
         super(builder);
       }
       private Annotation() {
@@ -56984,7 +56984,7 @@ protected java.lang.Object newInstance(
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_GeneratedCodeInfo_Annotation_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -57333,7 +57333,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
           output.writeInt32NoTag(path_.getInt(i));
         }
         if (((bitField0_ & 0x00000001) != 0)) {
-          com.google.protobuf.GeneratedMessageV3.writeString(output, 2, sourceFile_);
+          com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, sourceFile_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
           output.writeInt32(3, begin_);
@@ -57368,7 +57368,7 @@ public int getSerializedSize() {
           pathMemoizedSerializedSize = dataSize;
         }
         if (((bitField0_ & 0x00000001) != 0)) {
-          size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, sourceFile_);
+          size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, sourceFile_);
         }
         if (((bitField0_ & 0x00000002) != 0)) {
           size += com.google.protobuf.CodedOutputStream
@@ -57488,20 +57488,20 @@ public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation
       }
       public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation parseFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation parseFrom(
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
       public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation parseDelimitedFrom(java.io.InputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input);
       }
 
@@ -57509,20 +57509,20 @@ public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation
           java.io.InputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
       }
       public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation parseFrom(
           com.google.protobuf.CodedInputStream input)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input);
       }
       public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation parseFrom(
           com.google.protobuf.CodedInputStream input,
           com.google.protobuf.ExtensionRegistryLite extensionRegistry)
           throws java.io.IOException {
-        return com.google.protobuf.GeneratedMessageV3
+        return com.google.protobuf.GeneratedMessageV3Internal
             .parseWithIOException(PARSER, input, extensionRegistry);
       }
 
@@ -57542,7 +57542,7 @@ public Builder toBuilder() {
 
       @java.lang.Override
       protected Builder newBuilderForType(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         Builder builder = new Builder(parent);
         return builder;
       }
@@ -57550,7 +57550,7 @@ protected Builder newBuilderForType(
        * Protobuf type {@code google.protobuf.GeneratedCodeInfo.Annotation}
        */
       public static final class Builder extends
-          com.google.protobuf.GeneratedMessageV3.Builder implements
+          com.google.protobuf.GeneratedMessageV3Internal.Builder implements
           // @@protoc_insertion_point(builder_implements:google.protobuf.GeneratedCodeInfo.Annotation)
           com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.AnnotationOrBuilder {
         public static final com.google.protobuf.Descriptors.Descriptor
@@ -57559,7 +57559,7 @@ public static final class Builder extends
         }
 
         @java.lang.Override
-        protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+        protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
             internalGetFieldAccessorTable() {
           return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_GeneratedCodeInfo_Annotation_fieldAccessorTable
               .ensureFieldAccessorsInitialized(
@@ -57572,7 +57572,7 @@ private Builder() {
         }
 
         private Builder(
-            com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+            com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
           super(parent);
 
         }
@@ -57894,7 +57894,7 @@ public Builder addPath(int value) {
         public Builder addAllPath(
             java.lang.Iterable values) {
           ensurePathIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, path_);
           bitField0_ |= 0x00000001;
           onChanged();
@@ -58416,20 +58416,20 @@ public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseFrom(
     }
     public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseFrom(
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
     public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseDelimitedFrom(java.io.InputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input);
     }
 
@@ -58437,20 +58437,20 @@ public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseDelimi
         java.io.InputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
     }
     public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseFrom(
         com.google.protobuf.CodedInputStream input)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input);
     }
     public static com.google.protobuf.DescriptorProtos.GeneratedCodeInfo parseFrom(
         com.google.protobuf.CodedInputStream input,
         com.google.protobuf.ExtensionRegistryLite extensionRegistry)
         throws java.io.IOException {
-      return com.google.protobuf.GeneratedMessageV3
+      return com.google.protobuf.GeneratedMessageV3Internal
           .parseWithIOException(PARSER, input, extensionRegistry);
     }
 
@@ -58470,7 +58470,7 @@ public Builder toBuilder() {
 
     @java.lang.Override
     protected Builder newBuilderForType(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       Builder builder = new Builder(parent);
       return builder;
     }
@@ -58484,7 +58484,7 @@ protected Builder newBuilderForType(
      * Protobuf type {@code google.protobuf.GeneratedCodeInfo}
      */
     public static final class Builder extends
-        com.google.protobuf.GeneratedMessageV3.Builder implements
+        com.google.protobuf.GeneratedMessageV3Internal.Builder implements
         // @@protoc_insertion_point(builder_implements:google.protobuf.GeneratedCodeInfo)
         com.google.protobuf.DescriptorProtos.GeneratedCodeInfoOrBuilder {
       public static final com.google.protobuf.Descriptors.Descriptor
@@ -58493,7 +58493,7 @@ public static final class Builder extends
       }
 
       @java.lang.Override
-      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+      protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
           internalGetFieldAccessorTable() {
         return com.google.protobuf.DescriptorProtos.internal_static_google_protobuf_GeneratedCodeInfo_fieldAccessorTable
             .ensureFieldAccessorsInitialized(
@@ -58506,7 +58506,7 @@ private Builder() {
       }
 
       private Builder(
-          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+          com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
         super(parent);
 
       }
@@ -58632,7 +58632,7 @@ public Builder mergeFrom(com.google.protobuf.DescriptorProtos.GeneratedCodeInfo
               annotation_ = other.annotation_;
               bitField0_ = (bitField0_ & ~0x00000001);
               annotationBuilder_ = 
-                com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+                com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                    getAnnotationFieldBuilder() : null;
             } else {
               annotationBuilder_.addAllMessages(other.annotation_);
@@ -58704,8 +58704,8 @@ private void ensureAnnotationIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.AnnotationOrBuilder> annotationBuilder_;
+      private RepeatedFieldBuilderV3Internal<
+                Annotation, Annotation.Builder, AnnotationOrBuilder> annotationBuilder_;
 
       /**
        * 
@@ -58886,7 +58886,7 @@ public Builder addAllAnnotation(
           java.lang.Iterable values) {
         if (annotationBuilder_ == null) {
           ensureAnnotationIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.GeneratedMessageV3Internal.Builder.addAll(
               values, annotation_);
           onChanged();
         } else {
@@ -59010,12 +59010,12 @@ public com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation.Builder
            getAnnotationBuilderList() {
         return getAnnotationFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
-          com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.AnnotationOrBuilder> 
+      private RepeatedFieldBuilderV3Internal<
+                Annotation, Annotation.Builder, AnnotationOrBuilder>
           getAnnotationFieldBuilder() {
         if (annotationBuilder_ == null) {
-          annotationBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-              com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Annotation.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.AnnotationOrBuilder>(
+          annotationBuilder_ = new RepeatedFieldBuilderV3Internal<
+                        Annotation, Annotation.Builder, AnnotationOrBuilder>(
                   annotation_,
                   ((bitField0_ & 0x00000001) != 0),
                   getParentForChildren(),
@@ -59091,167 +59091,167 @@ public com.google.protobuf.DescriptorProtos.GeneratedCodeInfo getDefaultInstance
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FileDescriptorSet_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FileDescriptorSet_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FileDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FileDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_DescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_DescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_DescriptorProto_ExtensionRange_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_DescriptorProto_ExtensionRange_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_DescriptorProto_ReservedRange_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_DescriptorProto_ReservedRange_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_ExtensionRangeOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_ExtensionRangeOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_ExtensionRangeOptions_Declaration_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_ExtensionRangeOptions_Declaration_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FieldDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FieldDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_OneofDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_OneofDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumValueDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumValueDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_ServiceDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_ServiceDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_MethodDescriptorProto_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_MethodDescriptorProto_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FileOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FileOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_MessageOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_MessageOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FieldOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FieldOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FieldOptions_EditionDefault_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FieldOptions_EditionDefault_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FieldOptions_FeatureSupport_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FieldOptions_FeatureSupport_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_OneofOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_OneofOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumValueOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumValueOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_ServiceOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_ServiceOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_MethodOptions_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_MethodOptions_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_UninterpretedOption_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_UninterpretedOption_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_UninterpretedOption_NamePart_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_UninterpretedOption_NamePart_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FeatureSet_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FeatureSet_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FeatureSetDefaults_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FeatureSetDefaults_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_SourceCodeInfo_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_SourceCodeInfo_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_SourceCodeInfo_Location_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_SourceCodeInfo_Location_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_GeneratedCodeInfo_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_GeneratedCodeInfo_fieldAccessorTable;
   private static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_GeneratedCodeInfo_Annotation_descriptor;
   private static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_GeneratedCodeInfo_Annotation_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -59523,199 +59523,199 @@ public com.google.protobuf.DescriptorProtos.GeneratedCodeInfo getDefaultInstance
     internal_static_google_protobuf_FileDescriptorSet_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_FileDescriptorSet_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FileDescriptorSet_descriptor,
         new java.lang.String[] { "File", });
     internal_static_google_protobuf_FileDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(1);
     internal_static_google_protobuf_FileDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FileDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Package", "Dependency", "PublicDependency", "WeakDependency", "MessageType", "EnumType", "Service", "Extension", "Options", "SourceCodeInfo", "Syntax", "Edition", });
     internal_static_google_protobuf_DescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(2);
     internal_static_google_protobuf_DescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_DescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Field", "Extension", "NestedType", "EnumType", "ExtensionRange", "OneofDecl", "Options", "ReservedRange", "ReservedName", });
     internal_static_google_protobuf_DescriptorProto_ExtensionRange_descriptor =
       internal_static_google_protobuf_DescriptorProto_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_DescriptorProto_ExtensionRange_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_DescriptorProto_ExtensionRange_descriptor,
         new java.lang.String[] { "Start", "End", "Options", });
     internal_static_google_protobuf_DescriptorProto_ReservedRange_descriptor =
       internal_static_google_protobuf_DescriptorProto_descriptor.getNestedTypes().get(1);
     internal_static_google_protobuf_DescriptorProto_ReservedRange_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_DescriptorProto_ReservedRange_descriptor,
         new java.lang.String[] { "Start", "End", });
     internal_static_google_protobuf_ExtensionRangeOptions_descriptor =
       getDescriptor().getMessageTypes().get(3);
     internal_static_google_protobuf_ExtensionRangeOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_ExtensionRangeOptions_descriptor,
         new java.lang.String[] { "UninterpretedOption", "Declaration", "Features", "Verification", });
     internal_static_google_protobuf_ExtensionRangeOptions_Declaration_descriptor =
       internal_static_google_protobuf_ExtensionRangeOptions_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_ExtensionRangeOptions_Declaration_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_ExtensionRangeOptions_Declaration_descriptor,
         new java.lang.String[] { "Number", "FullName", "Type", "Reserved", "Repeated", });
     internal_static_google_protobuf_FieldDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(4);
     internal_static_google_protobuf_FieldDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FieldDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Number", "Label", "Type", "TypeName", "Extendee", "DefaultValue", "OneofIndex", "JsonName", "Options", "Proto3Optional", });
     internal_static_google_protobuf_OneofDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(5);
     internal_static_google_protobuf_OneofDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_OneofDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Options", });
     internal_static_google_protobuf_EnumDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(6);
     internal_static_google_protobuf_EnumDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Value", "Options", "ReservedRange", "ReservedName", });
     internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_descriptor =
       internal_static_google_protobuf_EnumDescriptorProto_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumDescriptorProto_EnumReservedRange_descriptor,
         new java.lang.String[] { "Start", "End", });
     internal_static_google_protobuf_EnumValueDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(7);
     internal_static_google_protobuf_EnumValueDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumValueDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Number", "Options", });
     internal_static_google_protobuf_ServiceDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(8);
     internal_static_google_protobuf_ServiceDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_ServiceDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "Method", "Options", });
     internal_static_google_protobuf_MethodDescriptorProto_descriptor =
       getDescriptor().getMessageTypes().get(9);
     internal_static_google_protobuf_MethodDescriptorProto_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_MethodDescriptorProto_descriptor,
         new java.lang.String[] { "Name", "InputType", "OutputType", "Options", "ClientStreaming", "ServerStreaming", });
     internal_static_google_protobuf_FileOptions_descriptor =
       getDescriptor().getMessageTypes().get(10);
     internal_static_google_protobuf_FileOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FileOptions_descriptor,
         new java.lang.String[] { "JavaPackage", "JavaOuterClassname", "JavaMultipleFiles", "JavaGenerateEqualsAndHash", "JavaStringCheckUtf8", "OptimizeFor", "GoPackage", "CcGenericServices", "JavaGenericServices", "PyGenericServices", "Deprecated", "CcEnableArenas", "ObjcClassPrefix", "CsharpNamespace", "SwiftPrefix", "PhpClassPrefix", "PhpNamespace", "PhpMetadataNamespace", "RubyPackage", "Features", "UninterpretedOption", });
     internal_static_google_protobuf_MessageOptions_descriptor =
       getDescriptor().getMessageTypes().get(11);
     internal_static_google_protobuf_MessageOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_MessageOptions_descriptor,
         new java.lang.String[] { "MessageSetWireFormat", "NoStandardDescriptorAccessor", "Deprecated", "MapEntry", "DeprecatedLegacyJsonFieldConflicts", "Features", "UninterpretedOption", });
     internal_static_google_protobuf_FieldOptions_descriptor =
       getDescriptor().getMessageTypes().get(12);
     internal_static_google_protobuf_FieldOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FieldOptions_descriptor,
         new java.lang.String[] { "Ctype", "Packed", "Jstype", "Lazy", "UnverifiedLazy", "Deprecated", "Weak", "DebugRedact", "Retention", "Targets", "EditionDefaults", "Features", "FeatureSupport", "UninterpretedOption", });
     internal_static_google_protobuf_FieldOptions_EditionDefault_descriptor =
       internal_static_google_protobuf_FieldOptions_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_FieldOptions_EditionDefault_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FieldOptions_EditionDefault_descriptor,
         new java.lang.String[] { "Edition", "Value", });
     internal_static_google_protobuf_FieldOptions_FeatureSupport_descriptor =
       internal_static_google_protobuf_FieldOptions_descriptor.getNestedTypes().get(1);
     internal_static_google_protobuf_FieldOptions_FeatureSupport_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FieldOptions_FeatureSupport_descriptor,
         new java.lang.String[] { "EditionIntroduced", "EditionDeprecated", "DeprecationWarning", "EditionRemoved", });
     internal_static_google_protobuf_OneofOptions_descriptor =
       getDescriptor().getMessageTypes().get(13);
     internal_static_google_protobuf_OneofOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_OneofOptions_descriptor,
         new java.lang.String[] { "Features", "UninterpretedOption", });
     internal_static_google_protobuf_EnumOptions_descriptor =
       getDescriptor().getMessageTypes().get(14);
     internal_static_google_protobuf_EnumOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumOptions_descriptor,
         new java.lang.String[] { "AllowAlias", "Deprecated", "DeprecatedLegacyJsonFieldConflicts", "Features", "UninterpretedOption", });
     internal_static_google_protobuf_EnumValueOptions_descriptor =
       getDescriptor().getMessageTypes().get(15);
     internal_static_google_protobuf_EnumValueOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumValueOptions_descriptor,
         new java.lang.String[] { "Deprecated", "Features", "DebugRedact", "FeatureSupport", "UninterpretedOption", });
     internal_static_google_protobuf_ServiceOptions_descriptor =
       getDescriptor().getMessageTypes().get(16);
     internal_static_google_protobuf_ServiceOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_ServiceOptions_descriptor,
         new java.lang.String[] { "Features", "Deprecated", "UninterpretedOption", });
     internal_static_google_protobuf_MethodOptions_descriptor =
       getDescriptor().getMessageTypes().get(17);
     internal_static_google_protobuf_MethodOptions_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_MethodOptions_descriptor,
         new java.lang.String[] { "Deprecated", "IdempotencyLevel", "Features", "UninterpretedOption", });
     internal_static_google_protobuf_UninterpretedOption_descriptor =
       getDescriptor().getMessageTypes().get(18);
     internal_static_google_protobuf_UninterpretedOption_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_UninterpretedOption_descriptor,
         new java.lang.String[] { "Name", "IdentifierValue", "PositiveIntValue", "NegativeIntValue", "DoubleValue", "StringValue", "AggregateValue", });
     internal_static_google_protobuf_UninterpretedOption_NamePart_descriptor =
       internal_static_google_protobuf_UninterpretedOption_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_UninterpretedOption_NamePart_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_UninterpretedOption_NamePart_descriptor,
         new java.lang.String[] { "NamePart", "IsExtension", });
     internal_static_google_protobuf_FeatureSet_descriptor =
       getDescriptor().getMessageTypes().get(19);
     internal_static_google_protobuf_FeatureSet_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FeatureSet_descriptor,
         new java.lang.String[] { "FieldPresence", "EnumType", "RepeatedFieldEncoding", "Utf8Validation", "MessageEncoding", "JsonFormat", });
     internal_static_google_protobuf_FeatureSetDefaults_descriptor =
       getDescriptor().getMessageTypes().get(20);
     internal_static_google_protobuf_FeatureSetDefaults_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FeatureSetDefaults_descriptor,
         new java.lang.String[] { "Defaults", "MinimumEdition", "MaximumEdition", });
     internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_descriptor =
       internal_static_google_protobuf_FeatureSetDefaults_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FeatureSetDefaults_FeatureSetEditionDefault_descriptor,
         new java.lang.String[] { "Edition", "OverridableFeatures", "FixedFeatures", });
     internal_static_google_protobuf_SourceCodeInfo_descriptor =
       getDescriptor().getMessageTypes().get(21);
     internal_static_google_protobuf_SourceCodeInfo_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_SourceCodeInfo_descriptor,
         new java.lang.String[] { "Location", });
     internal_static_google_protobuf_SourceCodeInfo_Location_descriptor =
       internal_static_google_protobuf_SourceCodeInfo_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_SourceCodeInfo_Location_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_SourceCodeInfo_Location_descriptor,
         new java.lang.String[] { "Path", "Span", "LeadingComments", "TrailingComments", "LeadingDetachedComments", });
     internal_static_google_protobuf_GeneratedCodeInfo_descriptor =
       getDescriptor().getMessageTypes().get(22);
     internal_static_google_protobuf_GeneratedCodeInfo_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_GeneratedCodeInfo_descriptor,
         new java.lang.String[] { "Annotation", });
     internal_static_google_protobuf_GeneratedCodeInfo_Annotation_descriptor =
       internal_static_google_protobuf_GeneratedCodeInfo_descriptor.getNestedTypes().get(0);
     internal_static_google_protobuf_GeneratedCodeInfo_Annotation_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_GeneratedCodeInfo_Annotation_descriptor,
         new java.lang.String[] { "Path", "SourceFile", "Begin", "End", "Semantic", });
   }
diff --git a/protobuf-api/src/main/java/com/google/protobuf/Descriptors.java b/protobuf-api/src/main/java/com/google/protobuf/Descriptors.java
index fb9b661..23d43aa 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/Descriptors.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Descriptors.java
@@ -1649,20 +1649,20 @@ private void crossLink() throws DescriptorValidationException {
             case INT32:
             case SINT32:
             case SFIXED32:
-              defaultValue = TextFormat.parseInt32(proto.getDefaultValue());
+              defaultValue = TextFormatInternal.parseInt32(proto.getDefaultValue());
               break;
             case UINT32:
             case FIXED32:
-              defaultValue = TextFormat.parseUInt32(proto.getDefaultValue());
+              defaultValue = TextFormatInternal.parseUInt32(proto.getDefaultValue());
               break;
             case INT64:
             case SINT64:
             case SFIXED64:
-              defaultValue = TextFormat.parseInt64(proto.getDefaultValue());
+              defaultValue = TextFormatInternal.parseInt64(proto.getDefaultValue());
               break;
             case UINT64:
             case FIXED64:
-              defaultValue = TextFormat.parseUInt64(proto.getDefaultValue());
+              defaultValue = TextFormatInternal.parseUInt64(proto.getDefaultValue());
               break;
             case FLOAT:
               if (proto.getDefaultValue().equals("inf")) {
@@ -1694,8 +1694,8 @@ private void crossLink() throws DescriptorValidationException {
               break;
             case BYTES:
               try {
-                defaultValue = TextFormat.unescapeBytes(proto.getDefaultValue());
-              } catch (TextFormat.InvalidEscapeSequenceException e) {
+                defaultValue = TextFormatEscaper.unescapeBytes(proto.getDefaultValue());
+              } catch (Exception e) {
                 throw new DescriptorValidationException(
                     this, "Couldn't parse default value: " + e.getMessage(), e);
               }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/DoubleValue.java b/protobuf-api/src/main/java/com/google/protobuf/DoubleValue.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/DoubleValue.java
rename to protobuf-api/src/main/java/com/google/protobuf/DoubleValue.java
index 974047a..725a829 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/DoubleValue.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/DoubleValue.java
@@ -14,12 +14,12 @@
  * Protobuf type {@code google.protobuf.DoubleValue}
  */
 public final class DoubleValue extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.DoubleValue)
     DoubleValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use DoubleValue.newBuilder() to construct.
-  private DoubleValue(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private DoubleValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private DoubleValue() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.WrappersProto.internal_static_google_protobuf_DoubleValue_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -161,20 +161,20 @@ public static com.google.protobuf.DoubleValue parseFrom(
   }
   public static com.google.protobuf.DoubleValue parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.DoubleValue parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.DoubleValue parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -182,20 +182,20 @@ public static com.google.protobuf.DoubleValue parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.DoubleValue parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.DoubleValue parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -215,7 +215,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -229,7 +229,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.DoubleValue}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.DoubleValue)
       com.google.protobuf.DoubleValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -238,7 +238,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.WrappersProto.internal_static_google_protobuf_DoubleValue_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -251,7 +251,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/DoubleValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/DoubleValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/DoubleValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/DoubleValueOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Duration.java b/protobuf-api/src/main/java/com/google/protobuf/Duration.java
similarity index 96%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Duration.java
rename to protobuf-api/src/main/java/com/google/protobuf/Duration.java
index b0679c0..13cdf17 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Duration.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Duration.java
@@ -69,12 +69,12 @@
  * Protobuf type {@code google.protobuf.Duration}
  */
 public final class Duration extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Duration)
     DurationOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Duration.newBuilder() to construct.
-  private Duration(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Duration(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Duration() {
@@ -93,7 +93,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.DurationProto.internal_static_google_protobuf_Duration_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -248,20 +248,20 @@ public static com.google.protobuf.Duration parseFrom(
   }
   public static com.google.protobuf.Duration parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Duration parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Duration parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -269,20 +269,20 @@ public static com.google.protobuf.Duration parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Duration parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Duration parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -302,7 +302,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -371,7 +371,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Duration}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Duration)
       com.google.protobuf.DurationOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -380,7 +380,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.DurationProto.internal_static_google_protobuf_Duration_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -393,7 +393,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/DurationOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/DurationOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/DurationOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/DurationOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/DurationProto.java b/protobuf-api/src/main/java/com/google/protobuf/DurationProto.java
similarity index 93%
rename from protobuf-sdk/src/main/java/com/google/protobuf/DurationProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/DurationProto.java
index cd13d21..7deb34e 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/DurationProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/DurationProto.java
@@ -18,7 +18,7 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Duration_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Duration_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -43,7 +43,7 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_Duration_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_Duration_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Duration_descriptor,
         new java.lang.String[] { "Seconds", "Nanos", });
   }
diff --git a/protobuf-api/src/main/java/com/google/protobuf/DynamicMessage.java b/protobuf-api/src/main/java/com/google/protobuf/DynamicMessage.java
index de98df0..578e362 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/DynamicMessage.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/DynamicMessage.java
@@ -26,7 +26,7 @@
  *
  * @author kenton@google.com Kenton Varda
  */
-public final class DynamicMessage extends AbstractMessage {
+public final class DynamicMessage extends FlattenedAbstractMessage {
   private final Descriptor type;
   private final FieldSet fields;
   private final FieldDescriptor[] oneofCases;
@@ -293,7 +293,7 @@ private void verifyOneofContainingType(OneofDescriptor oneof) {
   // =================================================================
 
   /** Builder for {@link DynamicMessage}s. */
-  public static final class Builder extends AbstractMessage.Builder {
+  public static final class Builder extends FlattenedAbstractMessage.Builder {
     private final Descriptor type;
     private FieldSet.Builder fields;
     private final FieldDescriptor[] oneofCases;
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Empty.java b/protobuf-api/src/main/java/com/google/protobuf/Empty.java
similarity index 93%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Empty.java
rename to protobuf-api/src/main/java/com/google/protobuf/Empty.java
index 04437a3..7b58465 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Empty.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Empty.java
@@ -18,12 +18,12 @@
  * Protobuf type {@code google.protobuf.Empty}
  */
 public final class Empty extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Empty)
     EmptyOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Empty.newBuilder() to construct.
-  private Empty(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Empty(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Empty() {
@@ -42,7 +42,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.EmptyProto.internal_static_google_protobuf_Empty_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -137,20 +137,20 @@ public static com.google.protobuf.Empty parseFrom(
   }
   public static com.google.protobuf.Empty parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Empty parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Empty parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -158,20 +158,20 @@ public static com.google.protobuf.Empty parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Empty parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Empty parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -191,7 +191,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -209,7 +209,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Empty}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Empty)
       com.google.protobuf.EmptyOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -218,7 +218,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.EmptyProto.internal_static_google_protobuf_Empty_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -231,7 +231,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/EmptyOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/EmptyOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/EmptyOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/EmptyOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/EmptyProto.java b/protobuf-api/src/main/java/com/google/protobuf/EmptyProto.java
similarity index 92%
rename from protobuf-sdk/src/main/java/com/google/protobuf/EmptyProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/EmptyProto.java
index 666acb2..6c4ee36 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/EmptyProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/EmptyProto.java
@@ -18,7 +18,7 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Empty_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Empty_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -42,7 +42,7 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_Empty_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_Empty_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Empty_descriptor,
         new java.lang.String[] { });
   }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Enum.java b/protobuf-api/src/main/java/com/google/protobuf/Enum.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Enum.java
rename to protobuf-api/src/main/java/com/google/protobuf/Enum.java
index 17f3bf8..e4c44b1 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Enum.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Enum.java
@@ -12,12 +12,12 @@
  * Protobuf type {@code google.protobuf.Enum}
  */
 public final class Enum extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Enum)
     EnumOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Enum.newBuilder() to construct.
-  private Enum(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Enum(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Enum() {
@@ -41,7 +41,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.TypeProto.internal_static_google_protobuf_Enum_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -343,8 +343,8 @@ public final boolean isInitialized() {
   @java.lang.Override
   public void writeTo(com.google.protobuf.CodedOutputStream output)
                       throws java.io.IOException {
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
     }
     for (int i = 0; i < enumvalue_.size(); i++) {
       output.writeMessage(2, enumvalue_.get(i));
@@ -358,8 +358,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
     if (syntax_ != com.google.protobuf.Syntax.SYNTAX_PROTO2.getNumber()) {
       output.writeEnum(5, syntax_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(edition_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 6, edition_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(edition_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 6, edition_);
     }
     getUnknownFields().writeTo(output);
   }
@@ -370,8 +370,8 @@ public int getSerializedSize() {
     if (size != -1) return size;
 
     size = 0;
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
     }
     for (int i = 0; i < enumvalue_.size(); i++) {
       size += com.google.protobuf.CodedOutputStream
@@ -389,8 +389,8 @@ public int getSerializedSize() {
       size += com.google.protobuf.CodedOutputStream
         .computeEnumSize(5, syntax_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(edition_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, edition_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(edition_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(6, edition_);
     }
     size += getUnknownFields().getSerializedSize();
     memoizedSize = size;
@@ -489,20 +489,20 @@ public static com.google.protobuf.Enum parseFrom(
   }
   public static com.google.protobuf.Enum parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Enum parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Enum parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -510,20 +510,20 @@ public static com.google.protobuf.Enum parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Enum parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Enum parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -543,7 +543,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -555,7 +555,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Enum}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Enum)
       com.google.protobuf.EnumOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -564,7 +564,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.TypeProto.internal_static_google_protobuf_Enum_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -577,12 +577,12 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
       maybeForceBuilderInitialization();
     }
     private void maybeForceBuilderInitialization() {
-      if (com.google.protobuf.GeneratedMessageV3
+      if (com.google.protobuf.GeneratedMessageV3Internal
               .alwaysUseFieldBuilders) {
         getEnumvalueFieldBuilder();
         getOptionsFieldBuilder();
@@ -757,7 +757,7 @@ public Builder mergeFrom(com.google.protobuf.Enum other) {
             enumvalue_ = other.enumvalue_;
             bitField0_ = (bitField0_ & ~0x00000002);
             enumvalueBuilder_ = 
-              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+              com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                  getEnumvalueFieldBuilder() : null;
           } else {
             enumvalueBuilder_.addAllMessages(other.enumvalue_);
@@ -783,7 +783,7 @@ public Builder mergeFrom(com.google.protobuf.Enum other) {
             options_ = other.options_;
             bitField0_ = (bitField0_ & ~0x00000004);
             optionsBuilder_ = 
-              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+              com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                  getOptionsFieldBuilder() : null;
           } else {
             optionsBuilder_.addAllMessages(other.options_);
@@ -993,8 +993,8 @@ private void ensureEnumvalueIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.EnumValue, com.google.protobuf.EnumValue.Builder, com.google.protobuf.EnumValueOrBuilder> enumvalueBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            EnumValue, EnumValue.Builder, EnumValueOrBuilder> enumvalueBuilder_;
 
     /**
      * 
@@ -1281,12 +1281,12 @@ public com.google.protobuf.EnumValue.Builder addEnumvalueBuilder(
          getEnumvalueBuilderList() {
       return getEnumvalueFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.EnumValue, com.google.protobuf.EnumValue.Builder, com.google.protobuf.EnumValueOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            EnumValue, EnumValue.Builder, EnumValueOrBuilder>
         getEnumvalueFieldBuilder() {
       if (enumvalueBuilder_ == null) {
-        enumvalueBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.EnumValue, com.google.protobuf.EnumValue.Builder, com.google.protobuf.EnumValueOrBuilder>(
+        enumvalueBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    EnumValue, EnumValue.Builder, EnumValueOrBuilder>(
                 enumvalue_,
                 ((bitField0_ & 0x00000002) != 0),
                 getParentForChildren(),
@@ -1305,8 +1305,8 @@ private void ensureOptionsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder> optionsBuilder_;
 
     /**
      * 
@@ -1593,12 +1593,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000004) != 0),
                 getParentForChildren(),
@@ -1609,8 +1609,8 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
     }
 
     private com.google.protobuf.SourceContext sourceContext_;
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> sourceContextBuilder_;
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder> sourceContextBuilder_;
     /**
      * 
      * The source context.
@@ -1751,12 +1751,12 @@ public com.google.protobuf.SourceContextOrBuilder getSourceContextOrBuilder() {
      *
      * .google.protobuf.SourceContext source_context = 4;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder>
         getSourceContextFieldBuilder() {
       if (sourceContextBuilder_ == null) {
-        sourceContextBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder>(
+        sourceContextBuilder_ = new SingleFieldBuilderV3Internal<
+                    SourceContext, SourceContext.Builder, SourceContextOrBuilder>(
                 getSourceContext(),
                 getParentForChildren(),
                 isClean());
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/EnumOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/EnumOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/EnumOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/EnumOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/EnumValue.java b/protobuf-api/src/main/java/com/google/protobuf/EnumValue.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/EnumValue.java
rename to protobuf-api/src/main/java/com/google/protobuf/EnumValue.java
index 62634f4..41c3bf9 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/EnumValue.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/EnumValue.java
@@ -12,12 +12,12 @@
  * Protobuf type {@code google.protobuf.EnumValue}
  */
 public final class EnumValue extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.EnumValue)
     EnumValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use EnumValue.newBuilder() to construct.
-  private EnumValue(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private EnumValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private EnumValue() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.TypeProto.internal_static_google_protobuf_EnumValue_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -182,8 +182,8 @@ public final boolean isInitialized() {
   @java.lang.Override
   public void writeTo(com.google.protobuf.CodedOutputStream output)
                       throws java.io.IOException {
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
     }
     if (number_ != 0) {
       output.writeInt32(2, number_);
@@ -200,8 +200,8 @@ public int getSerializedSize() {
     if (size != -1) return size;
 
     size = 0;
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
     }
     if (number_ != 0) {
       size += com.google.protobuf.CodedOutputStream
@@ -290,20 +290,20 @@ public static com.google.protobuf.EnumValue parseFrom(
   }
   public static com.google.protobuf.EnumValue parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.EnumValue parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.EnumValue parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -311,20 +311,20 @@ public static com.google.protobuf.EnumValue parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.EnumValue parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.EnumValue parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -344,7 +344,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -356,7 +356,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.EnumValue}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.EnumValue)
       com.google.protobuf.EnumValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -365,7 +365,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.TypeProto.internal_static_google_protobuf_EnumValue_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -378,7 +378,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
@@ -520,7 +520,7 @@ public Builder mergeFrom(com.google.protobuf.EnumValue other) {
             options_ = other.options_;
             bitField0_ = (bitField0_ & ~0x00000004);
             optionsBuilder_ = 
-              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+              com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                  getOptionsFieldBuilder() : null;
           } else {
             optionsBuilder_.addAllMessages(other.options_);
@@ -738,8 +738,8 @@ private void ensureOptionsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder> optionsBuilder_;
 
     /**
      * 
@@ -1026,12 +1026,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000004) != 0),
                 getParentForChildren(),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/EnumValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/EnumValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/EnumValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/EnumValueOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistry.java b/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistry.java
index 39babd3..665eee4 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistry.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistry.java
@@ -200,10 +200,11 @@ public void add(final Extension extension) {
     add(newExtensionInfo(extension), extension.getExtensionType());
   }
 
-  /** Add an extension from a generated file to the registry. */
-  public void add(final GeneratedMessage.GeneratedExtension extension) {
-    add((Extension) extension);
-  }
+  //This method should be deprecated and then removed.
+//  /** Add an extension from a generated file to the registry. */
+//  public void add(final GeneratedMessage.GeneratedExtension extension) {
+//    add((Extension) extension);
+//  }
 
   static ExtensionInfo newExtensionInfo(final Extension extension) {
     if (extension.getDescriptor().getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
diff --git a/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistryLite.java b/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
index 18d14bf..0bd38f6 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/ExtensionRegistryLite.java
@@ -7,6 +7,7 @@
 
 package com.google.protobuf;
 
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
@@ -127,17 +128,17 @@ public ExtensionRegistryLite getUnmodifiable() {
    */
   @SuppressWarnings("unchecked")
   public 
-      GeneratedMessageLite.GeneratedExtension findLiteExtensionByNumber(
+  GeneratedMessageLite.GeneratedExtension findLiteExtensionByNumber(
           final ContainingType containingTypeDefaultInstance, final int fieldNumber) {
     return (GeneratedMessageLite.GeneratedExtension)
-        extensionsByNumber.get(new ObjectIntPair(containingTypeDefaultInstance, fieldNumber));
+            extensionsByNumber.get(new ObjectIntPair(containingTypeDefaultInstance, fieldNumber));
   }
 
   /** Add an extension from a lite generated file to the registry. */
   public final void add(final GeneratedMessageLite.GeneratedExtension extension) {
     extensionsByNumber.put(
-        new ObjectIntPair(extension.getContainingTypeDefaultInstance(), extension.getNumber()),
-        extension);
+            new ObjectIntPair(extension.getContainingTypeDefaultInstance(), extension.getNumber()),
+            extension);
   }
 
   /**
@@ -153,7 +154,7 @@ public final void add(ExtensionLite extension) {
         this.getClass().getMethod("add", ExtensionClassHolder.INSTANCE).invoke(this, extension);
       } catch (Exception e) {
         throw new IllegalArgumentException(
-            String.format("Could not invoke ExtensionRegistry#add for %s", extension), e);
+                String.format("Could not invoke ExtensionRegistry#add for %s", extension), e);
       }
     }
   }
@@ -166,7 +167,7 @@ public final void add(ExtensionLite extension) {
 
   ExtensionRegistryLite() {
     this.extensionsByNumber =
-        new HashMap>();
+        new HashMap>();
   }
 
   static final ExtensionRegistryLite EMPTY_REGISTRY_LITE = new ExtensionRegistryLite(true);
@@ -179,7 +180,7 @@ public final void add(ExtensionLite extension) {
     }
   }
 
-  private final Map>
+  private final Map>
       extensionsByNumber;
 
   ExtensionRegistryLite(boolean empty) {
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Field.java b/protobuf-api/src/main/java/com/google/protobuf/Field.java
similarity index 96%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Field.java
rename to protobuf-api/src/main/java/com/google/protobuf/Field.java
index 0cd180b..566c163 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Field.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Field.java
@@ -12,12 +12,12 @@
  * Protobuf type {@code google.protobuf.Field}
  */
 public final class Field extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Field)
     FieldOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Field.newBuilder() to construct.
-  private Field(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Field(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Field() {
@@ -43,7 +43,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.TypeProto.internal_static_google_protobuf_Field_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -1001,11 +1001,11 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
     if (number_ != 0) {
       output.writeInt32(3, number_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 4, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 4, name_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(typeUrl_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 6, typeUrl_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(typeUrl_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 6, typeUrl_);
     }
     if (oneofIndex_ != 0) {
       output.writeInt32(7, oneofIndex_);
@@ -1016,11 +1016,11 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
     for (int i = 0; i < options_.size(); i++) {
       output.writeMessage(9, options_.get(i));
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(jsonName_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 10, jsonName_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(jsonName_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 10, jsonName_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(defaultValue_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 11, defaultValue_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(defaultValue_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 11, defaultValue_);
     }
     getUnknownFields().writeTo(output);
   }
@@ -1043,11 +1043,11 @@ public int getSerializedSize() {
       size += com.google.protobuf.CodedOutputStream
         .computeInt32Size(3, number_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(4, name_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(typeUrl_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, typeUrl_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(typeUrl_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(6, typeUrl_);
     }
     if (oneofIndex_ != 0) {
       size += com.google.protobuf.CodedOutputStream
@@ -1061,11 +1061,11 @@ public int getSerializedSize() {
       size += com.google.protobuf.CodedOutputStream
         .computeMessageSize(9, options_.get(i));
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(jsonName_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(10, jsonName_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(jsonName_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(10, jsonName_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(defaultValue_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(11, defaultValue_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(defaultValue_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(11, defaultValue_);
     }
     size += getUnknownFields().getSerializedSize();
     memoizedSize = size;
@@ -1173,20 +1173,20 @@ public static com.google.protobuf.Field parseFrom(
   }
   public static com.google.protobuf.Field parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Field parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Field parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -1194,20 +1194,20 @@ public static com.google.protobuf.Field parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Field parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Field parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -1227,7 +1227,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -1239,7 +1239,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Field}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Field)
       com.google.protobuf.FieldOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -1248,7 +1248,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.TypeProto.internal_static_google_protobuf_Field_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -1261,7 +1261,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
@@ -1448,7 +1448,7 @@ public Builder mergeFrom(com.google.protobuf.Field other) {
             options_ = other.options_;
             bitField0_ = (bitField0_ & ~0x00000080);
             optionsBuilder_ = 
-              com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
+              com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ?
                  getOptionsFieldBuilder() : null;
           } else {
             optionsBuilder_.addAllMessages(other.options_);
@@ -2045,8 +2045,8 @@ private void ensureOptionsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder> optionsBuilder_;
 
     /**
      * 
@@ -2333,12 +2333,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000080) != 0),
                 getParentForChildren(),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FieldMask.java b/protobuf-api/src/main/java/com/google/protobuf/FieldMask.java
similarity index 96%
rename from protobuf-sdk/src/main/java/com/google/protobuf/FieldMask.java
rename to protobuf-api/src/main/java/com/google/protobuf/FieldMask.java
index 5aab429..e96c5f9 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/FieldMask.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/FieldMask.java
@@ -210,12 +210,12 @@
  * Protobuf type {@code google.protobuf.FieldMask}
  */
 public final class FieldMask extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.FieldMask)
     FieldMaskOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use FieldMask.newBuilder() to construct.
-  private FieldMask(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private FieldMask(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private FieldMask() {
@@ -236,7 +236,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.FieldMaskProto.internal_static_google_protobuf_FieldMask_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -311,7 +311,7 @@ public final boolean isInitialized() {
   public void writeTo(com.google.protobuf.CodedOutputStream output)
                       throws java.io.IOException {
     for (int i = 0; i < paths_.size(); i++) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, paths_.getRaw(i));
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, paths_.getRaw(i));
     }
     getUnknownFields().writeTo(output);
   }
@@ -401,20 +401,20 @@ public static com.google.protobuf.FieldMask parseFrom(
   }
   public static com.google.protobuf.FieldMask parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.FieldMask parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.FieldMask parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -422,20 +422,20 @@ public static com.google.protobuf.FieldMask parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.FieldMask parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.FieldMask parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -455,7 +455,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -665,7 +665,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.FieldMask}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.FieldMask)
       com.google.protobuf.FieldMaskOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -674,7 +674,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.FieldMaskProto.internal_static_google_protobuf_FieldMask_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -687,7 +687,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FieldMaskOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/FieldMaskOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/FieldMaskOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/FieldMaskOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FieldMaskProto.java b/protobuf-api/src/main/java/com/google/protobuf/FieldMaskProto.java
similarity index 92%
rename from protobuf-sdk/src/main/java/com/google/protobuf/FieldMaskProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/FieldMaskProto.java
index cfc5499..396e60c 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/FieldMaskProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/FieldMaskProto.java
@@ -18,7 +18,7 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FieldMask_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FieldMask_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -43,7 +43,7 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_FieldMask_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_FieldMask_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FieldMask_descriptor,
         new java.lang.String[] { "Paths", });
   }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FieldOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/FieldOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/FieldOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/FieldOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/FlattenedAbstractMessage.java b/protobuf-api/src/main/java/com/google/protobuf/FlattenedAbstractMessage.java
new file mode 100644
index 0000000..c5542d2
--- /dev/null
+++ b/protobuf-api/src/main/java/com/google/protobuf/FlattenedAbstractMessage.java
@@ -0,0 +1,841 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
+
+package com.google.protobuf;
+
+import com.google.protobuf.Descriptors.EnumValueDescriptor;
+import com.google.protobuf.Descriptors.FieldDescriptor;
+import com.google.protobuf.Descriptors.OneofDescriptor;
+import com.google.protobuf.Internal.EnumLite;
+
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import static com.google.protobuf.Internal.checkNotNull;
+
+/**
+ * A partial implementation of the {@link Message} interface which implements as many methods of
+ * that interface as possible in terms of other methods.
+ *
+ * @author kenton@google.com Kenton Varda
+ */
+public abstract class FlattenedAbstractMessage
+    // TODO: Update GeneratedMessage to parameterize with MessageType and BuilderType.
+ implements Message {
+
+  protected int memoizedHashCode = 0;
+
+  @Override
+  public ByteString toByteString() {
+    try {
+      final ByteString.CodedBuilder out = ByteString.newCodedBuilder(getSerializedSize());
+      writeTo(out.getCodedOutput());
+      return out.build();
+    } catch (IOException e) {
+      throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e);
+    }
+  }
+
+  @Override
+  public byte[] toByteArray() {
+    try {
+      final byte[] result = new byte[getSerializedSize()];
+      final CodedOutputStream output = CodedOutputStream.newInstance(result);
+      writeTo(output);
+      output.checkNoSpaceLeft();
+      return result;
+    } catch (IOException e) {
+      throw new RuntimeException(getSerializingExceptionMessage("byte array"), e);
+    }
+  }
+
+  @Override
+  public void writeTo(final OutputStream output) throws IOException {
+    final int bufferSize = CodedOutputStream.computePreferredBufferSize(getSerializedSize());
+    final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize);
+    writeTo(codedOutput);
+    codedOutput.flush();
+  }
+
+  @Override
+  public void writeDelimitedTo(final OutputStream output) throws IOException {
+    final int serialized = getSerializedSize();
+    final int bufferSize =
+            CodedOutputStream.computePreferredBufferSize(
+                    CodedOutputStream.computeUInt32SizeNoTag(serialized) + serialized);
+    final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize);
+    codedOutput.writeUInt32NoTag(serialized);
+    writeTo(codedOutput);
+    codedOutput.flush();
+  }
+
+  int getSerializedSize(
+          Schema schema) {
+    int memoizedSerializedSize = getMemoizedSerializedSize();
+    if (memoizedSerializedSize == -1) {
+      memoizedSerializedSize = schema.getSerializedSize(this);
+      setMemoizedSerializedSize(memoizedSerializedSize);
+    }
+    return memoizedSerializedSize;
+  }
+
+  private String getSerializingExceptionMessage(String target) {
+    return "Serializing "
+            + getClass().getName()
+            + " to a "
+            + target
+            + " threw an IOException (should never happen).";
+  }
+
+  protected static void checkByteStringIsUtf8(ByteString byteString)
+          throws IllegalArgumentException {
+    if (!byteString.isValidUtf8()) {
+      throw new IllegalArgumentException("Byte string is not UTF-8.");
+    }
+  }
+
+  /** Interface for an enum which signifies which field in a {@code oneof} was specified. */
+  protected interface InternalOneOfEnum {
+    /**
+     * Retrieves the field number of the field which was set in this {@code oneof}, or {@code 0} if
+     * none were.
+     */
+    int getNumber();
+  }
+
+  @Override
+  public boolean isInitialized() {
+    return MessageReflection.isInitialized(this);
+  }
+
+  /**
+   * Interface for the parent of a Builder that allows the builder to communicate invalidations back
+   * to the parent for use when using nested builders.
+   */
+  protected interface BuilderParent {
+
+    /**
+     * A builder becomes dirty whenever a field is modified -- including fields in nested builders
+     * -- and becomes clean when build() is called. Thus, when a builder becomes dirty, all its
+     * parents become dirty as well, and when it becomes clean, all its children become clean. The
+     * dirtiness state is used to invalidate certain cached values.
+     *
+     * 

To this end, a builder calls markDirty() on its parent whenever it transitions from clean + * to dirty. The parent must propagate this call to its own parent, unless it was already dirty, + * in which case the grandparent must necessarily already be dirty as well. The parent can only + * transition back to "clean" after calling build() on all children. + */ + void markDirty(); + } + + /** Create a nested builder. */ + protected Message.Builder newBuilderForType(BuilderParent parent) { + throw new UnsupportedOperationException("Nested builder is not supported for this type."); + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public boolean hasOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + @Override + public final String toString() { + return TextFormatInternal.printer().printToString(this); + } + + @Override + public void writeTo(final CodedOutputStream output) throws IOException { + MessageReflection.writeMessageTo(this, getAllFields(), output, false); + } + + protected int memoizedSize = -1; + + int getMemoizedSerializedSize() { + return memoizedSize; + } + + void setMemoizedSerializedSize(int size) { + memoizedSize = size; + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) { + return size; + } + + memoizedSize = MessageReflection.getSerializedSize(this, getAllFields()); + return memoizedSize; + } + + @Override + public boolean equals(final Object other) { + if (other == this) { + return true; + } + if (!(other instanceof Message)) { + return false; + } + final Message otherMessage = (Message) other; + if (getDescriptorForType() != otherMessage.getDescriptorForType()) { + return false; + } + return compareFields(getAllFields(), otherMessage.getAllFields()) + && getUnknownFields().equals(otherMessage.getUnknownFields()); + } + + @Override + public int hashCode() { + int hash = memoizedHashCode; + if (hash == 0) { + hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = hashFields(hash, getAllFields()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + } + return hash; + } + + private static ByteString toByteString(Object value) { + if (value instanceof byte[]) { + return ByteString.copyFrom((byte[]) value); + } else { + return (ByteString) value; + } + } + + /** + * Compares two bytes fields. The parameters must be either a byte array or a ByteString object. + * They can be of different type though. + */ + private static boolean compareBytes(Object a, Object b) { + if (a instanceof byte[] && b instanceof byte[]) { + return Arrays.equals((byte[]) a, (byte[]) b); + } + return toByteString(a).equals(toByteString(b)); + } + + /** Converts a list of MapEntry messages into a Map used for equals() and hashCode(). */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static Map convertMapEntryListToMap(List list) { + if (list.isEmpty()) { + return Collections.emptyMap(); + } + Map result = new HashMap<>(); + Iterator iterator = list.iterator(); + Message entry = (Message) iterator.next(); + Descriptors.Descriptor descriptor = entry.getDescriptorForType(); + FieldDescriptor key = descriptor.findFieldByName("key"); + FieldDescriptor value = descriptor.findFieldByName("value"); + Object fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + while (iterator.hasNext()) { + entry = (Message) iterator.next(); + fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + } + return result; + } + + /** Compares two map fields. The parameters must be a list of MapEntry messages. */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static boolean compareMapField(Object a, Object b) { + Map ma = convertMapEntryListToMap((List) a); + Map mb = convertMapEntryListToMap((List) b); + return MapFieldLite.equals(ma, mb); + } + + /** + * Compares two sets of fields. This method is used to implement {@link + * FlattenedAbstractMessage#equals(Object)} and {@link AbstractMutableMessage#equals(Object)}. It takes + * special care of bytes fields because immutable messages and mutable messages use different Java + * type to represent a bytes field and this method should be able to compare immutable messages, + * mutable messages and also an immutable message to a mutable message. + */ + static boolean compareFields(Map a, Map b) { + if (a.size() != b.size()) { + return false; + } + for (FieldDescriptor descriptor : a.keySet()) { + if (!b.containsKey(descriptor)) { + return false; + } + Object value1 = a.get(descriptor); + Object value2 = b.get(descriptor); + if (descriptor.getType() == FieldDescriptor.Type.BYTES) { + if (descriptor.isRepeated()) { + List list1 = (List) value1; + List list2 = (List) value2; + if (list1.size() != list2.size()) { + return false; + } + for (int i = 0; i < list1.size(); i++) { + if (!compareBytes(list1.get(i), list2.get(i))) { + return false; + } + } + } else { + // Compares a singular bytes field. + if (!compareBytes(value1, value2)) { + return false; + } + } + } else if (descriptor.isMapField()) { + if (!compareMapField(value1, value2)) { + return false; + } + } else { + // Compare non-bytes fields. + if (!value1.equals(value2)) { + return false; + } + } + } + return true; + } + + /** Calculates the hash code of a map field. {@code value} must be a list of MapEntry messages. */ + @SuppressWarnings("unchecked") + private static int hashMapField(Object value) { + return MapFieldLite.calculateHashCodeForMap(convertMapEntryListToMap((List) value)); + } + + /** Get a hash code for given fields and values, using the given seed. */ + @SuppressWarnings("unchecked") + protected static int hashFields(int hash, Map map) { + for (Map.Entry entry : map.entrySet()) { + FieldDescriptor field = entry.getKey(); + Object value = entry.getValue(); + hash = (37 * hash) + field.getNumber(); + if (field.isMapField()) { + hash = (53 * hash) + hashMapField(value); + } else if (field.getType() != FieldDescriptor.Type.ENUM) { + hash = (53 * hash) + value.hashCode(); + } else if (field.isRepeated()) { + List list = (List) value; + hash = (53 * hash) + Internal.hashEnumList(list); + } else { + hash = (53 * hash) + Internal.hashEnum((EnumLite) value); + } + } + return hash; + } + + /** + * Package private helper method for AbstractParser to create UninitializedMessageException with + * missing field information. + */ + UninitializedMessageException newUninitializedMessageException() { + return Builder.newUninitializedMessageException(this); + } + + // ================================================================= + + /** + * A partial implementation of the {@link Message.Builder} interface which implements as many + * methods of that interface as possible in terms of other methods. + */ + @SuppressWarnings("unchecked") + public abstract static class Builder> implements Message.Builder { + + /** + * An InputStream implementations which reads from some other InputStream but is limited to a + * particular number of bytes. Used by mergeDelimitedFrom(). This is intentionally + * package-private so that UnknownFieldSet can share it. + */ + static final class LimitedInputStream extends FilterInputStream { + private int limit; + + LimitedInputStream(InputStream in, int limit) { + super(in); + this.limit = limit; + } + + @Override + public int available() throws IOException { + return Math.min(super.available(), limit); + } + + @Override + public int read() throws IOException { + if (limit <= 0) { + return -1; + } + final int result = super.read(); + if (result >= 0) { + --limit; + } + return result; + } + + @Override + public int read(final byte[] b, final int off, int len) throws IOException { + if (limit <= 0) { + return -1; + } + len = Math.min(len, limit); + final int result = super.read(b, off, len); + if (result >= 0) { + limit -= result; + } + return result; + } + + @Override + public long skip(final long n) throws IOException { + // because we take the minimum of an int and a long, result is guaranteed to be + // less than or equal to Integer.MAX_INT so this cast is safe + int result = (int) super.skip(Math.min(n, limit)); + if (result >= 0) { + // if the superclass adheres to the contract for skip, this condition is always true + limit -= result; + } + return result; + } + } + + @Override + public boolean mergeDelimitedFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final int firstByte = input.read(); + if (firstByte == -1) { + return false; + } + final int size = CodedInputStream.readRawVarint32(firstByte, input); + final InputStream limitedInput = new LimitedInputStream(input, size); + mergeFrom(limitedInput, extensionRegistry); + return true; + } + + @Override + public boolean mergeDelimitedFrom(final InputStream input) throws IOException { + return mergeDelimitedFrom(input, ExtensionRegistryLite.getEmptyRegistry()); + } + + @Override + @SuppressWarnings("unchecked") // isInstance takes care of this + public BuilderType mergeFrom(final MessageLite other) { + if (!getDefaultInstanceForType().getClass().isInstance(other)) { + throw new IllegalArgumentException( + "mergeFrom(MessageLite) can only merge messages of the same type."); + } + + return internalMergeFrom(other); + } + + private String getReadingExceptionMessage(String target) { + return "Reading " + + getClass().getName() + + " from a " + + target + + " threw an IOException (should never happen)."; + } + + // We check nulls as we iterate to avoid iterating over values twice. + private static void addAllCheckingNulls(Iterable values, List list) { + if (list instanceof ArrayList && values instanceof Collection) { + ((ArrayList) list).ensureCapacity(list.size() + ((Collection) values).size()); + } + int begin = list.size(); + for (T value : values) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (list.size() - begin) + " is null."; + for (int i = list.size() - 1; i >= begin; i--) { + list.remove(i); + } + throw new NullPointerException(message); + } + list.add(value); + } + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + MessageLite message) { + return new UninitializedMessageException(message); + } + + // For binary compatibility. + @Deprecated + protected static void addAll(final Iterable values, final Collection list) { + addAll(values, (List) list); + } + + /** + * Adds the {@code values} to the {@code list}. This is a helper method used by generated code. + * Users should ignore it. + * + * @throws NullPointerException if {@code values} or any of the elements of {@code values} is + * null. + */ + protected static void addAll(final Iterable values, final List list) { + checkNotNull(values); + if (values instanceof LazyStringList) { + // For StringOrByteStringLists, check the underlying elements to avoid + // forcing conversions of ByteStrings to Strings. + // TODO: Could we just prohibit nulls in all protobuf lists and get rid of this? Is + // if even possible to hit this condition as all protobuf methods check for null first, + // right? + List lazyValues = ((LazyStringList) values).getUnderlyingElements(); + LazyStringList lazyList = (LazyStringList) list; + int begin = list.size(); + for (Object value : lazyValues) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (lazyList.size() - begin) + " is null."; + for (int i = lazyList.size() - 1; i >= begin; i--) { + lazyList.remove(i); + } + throw new NullPointerException(message); + } + if (value instanceof ByteString) { + lazyList.add((ByteString) value); + } else { + lazyList.add((String) value); + } + } + } else { + if (values instanceof PrimitiveNonBoxingCollection) { + list.addAll((Collection) values); + } else { + addAllCheckingNulls(values, list); + } + } + } + + // The compiler produces an error if this is not declared explicitly. + // Method isn't abstract to bypass Java 1.6 compiler issue: + // http://bugs.java.com/view_bug.do?bug_id=6908259 + @Override + public BuilderType clone() { + throw new UnsupportedOperationException("clone() should be implemented in subclasses."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public boolean hasOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public FieldDescriptor getOneofFieldDescriptor(OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public BuilderType clearOneof(OneofDescriptor oneof) { + throw new UnsupportedOperationException("clearOneof() is not implemented."); + } + + @Override + public BuilderType clear() { + for (final Map.Entry entry : getAllFields().entrySet()) { + clearField(entry.getKey()); + } + return (BuilderType) this; + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + protected BuilderType internalMergeFrom(MessageLite other) { + return mergeFrom((Message) other); + } + + @Override + public BuilderType mergeFrom(final Message other) { + return mergeFrom(other, other.getAllFields()); + } + + BuilderType mergeFrom(final Message other, Map allFields) { + if (other.getDescriptorForType() != getDescriptorForType()) { + throw new IllegalArgumentException( + "mergeFrom(Message) can only merge messages of the same type."); + } + + // Note: We don't attempt to verify that other's fields have valid + // types. Doing so would be a losing battle. We'd have to verify + // all sub-messages as well, and we'd have to make copies of all of + // them to insure that they don't change after verification (since + // the Message interface itself cannot enforce immutability of + // implementations). + + for (final Map.Entry entry : allFields.entrySet()) { + final FieldDescriptor field = entry.getKey(); + if (field.isRepeated()) { + for (final Object element : (List) entry.getValue()) { + addRepeatedField(field, element); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + final Message existingValue = (Message) getField(field); + if (existingValue == existingValue.getDefaultInstanceForType()) { + setField(field, entry.getValue()); + } else { + setField( + field, + existingValue + .newBuilderForType() + .mergeFrom(existingValue) + .mergeFrom((Message) entry.getValue()) + .build()); + } + } else { + setField(field, entry.getValue()); + } + } + + mergeUnknownFields(other.getUnknownFields()); + + return (BuilderType) this; + } + + @Override + public BuilderType mergeFrom(final CodedInputStream input) throws IOException { + return mergeFrom(input, ExtensionRegistry.getEmptyRegistry()); + } + + @Override + public BuilderType mergeFrom( + final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) + throws IOException { + boolean discardUnknown = input.shouldDiscardUnknownFields(); + final UnknownFieldSet.Builder unknownFields = + discardUnknown ? null : getUnknownFieldSetBuilder(); + MessageReflection.mergeMessageFrom(this, unknownFields, input, extensionRegistry); + if (unknownFields != null) { + setUnknownFieldSetBuilder(unknownFields); + } + return (BuilderType) this; + } + + protected UnknownFieldSet.Builder getUnknownFieldSetBuilder() { + return UnknownFieldSet.newBuilder(getUnknownFields()); + } + + protected void setUnknownFieldSetBuilder(final UnknownFieldSet.Builder builder) { + setUnknownFields(builder.build()); + } + + @Override + public BuilderType mergeUnknownFields(final UnknownFieldSet unknownFields) { + setUnknownFields( + UnknownFieldSet.newBuilder(getUnknownFields()).mergeFrom(unknownFields).build()); + return (BuilderType) this; + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on an unsupported message type."); + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on an unsupported message type."); + } + + @Override + public String toString() { + return TextFormatInternal.printer().printToString(this); + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + Message message) { + return new UninitializedMessageException(MessageReflection.findMissingFields(message)); + } + + // =============================================================== + // The following definitions seem to be required in order to make javac + // not produce weird errors like: + // + // java/com/google/protobuf/DynamicMessage.java:203: types + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> and + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> are incompatible; both + // define mergeFrom(com.google.protobuf.ByteString), but with unrelated + // return types. + // + // Strangely, these lines are only needed if javac is invoked separately + // on AbstractMessage.java and AbstractMessageLite.java. If javac is + // invoked on both simultaneously, it works. (Or maybe the important + // point is whether or not DynamicMessage.java is compiled together with + // AbstractMessageLite.java -- not sure.) I suspect this is a compiler + // bug. + + public BuilderType mergeFrom(final ByteString data) throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input); + input.checkLastTagWas(0); + return (BuilderType) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public BuilderType mergeFrom( + final ByteString data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (BuilderType) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public BuilderType mergeFrom(final byte[] data) throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length); + } + + public BuilderType mergeFrom(final byte[] data, final int off, final int len) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input); + input.checkLastTagWas(0); + return (BuilderType) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public BuilderType mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length, extensionRegistry); + } + + public BuilderType mergeFrom( + final byte[] data, + final int off, + final int len, + final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (BuilderType) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public BuilderType mergeFrom(final InputStream input) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput); + codedInput.checkLastTagWas(0); + return (BuilderType) this; + } + + public BuilderType mergeFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput, extensionRegistry); + codedInput.checkLastTagWas(0); + return (BuilderType) this; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashLong(long n) { + return (int) (n ^ (n >>> 32)); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashBoolean(boolean b) { + return b ? 1231 : 1237; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnum(EnumLite e) { + return e.getNumber(); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnumList(List list) { + int hash = 1; + for (EnumLite e : list) { + hash = 31 * hash + hashEnum(e); + } + return hash; + } +} +} diff --git a/protobuf-api/src/main/java/com/google/protobuf/FlattenedGeneratedMessageV3.java b/protobuf-api/src/main/java/com/google/protobuf/FlattenedGeneratedMessageV3.java new file mode 100644 index 0000000..1d0eade --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/FlattenedGeneratedMessageV3.java @@ -0,0 +1,4302 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf; + +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.EnumDescriptor; +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.FileDescriptor; +import com.google.protobuf.Descriptors.OneofDescriptor; +import com.google.protobuf.Internal.BooleanList; +import com.google.protobuf.Internal.DoubleList; +import com.google.protobuf.Internal.FloatList; +import com.google.protobuf.Internal.IntList; +import com.google.protobuf.Internal.LongList; +import com.google.protobuf.Internal.ProtobufList; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectStreamException; +import java.io.OutputStream; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +import static com.google.protobuf.Internal.checkNotNull; + +/** + * All generated protocol message classes extend this class. This class implements most of the + * Message and Builder interfaces using Java reflection. Users can ignore this class and pretend + * that generated messages implement the Message interface directly. + * + * @author kenton@google.com Kenton Varda + */ +abstract class FlattenedGeneratedMessageV3 implements Message, Serializable { + private static final long serialVersionUID = 1L; + + /** + * For testing. Allows a test to disable the optimization that avoids using field builders for + * nested messages until they are requested. By disabling this optimization, existing tests can be + * reused to test the field builders. + */ + protected static boolean alwaysUseFieldBuilders = false; + + /** + * For use by generated code only. + * + *

TODO: mark this private and final (breaking change) + */ + protected UnknownFieldSet unknownFields; + + protected FlattenedGeneratedMessageV3() { + unknownFields = UnknownFieldSet.getDefaultInstance(); + } + + protected FlattenedGeneratedMessageV3(Builder builder) { + unknownFields = builder.getUnknownFields(); + } + + protected int memoizedHashCode = 0; + + public ByteString toByteString() { + try { + final ByteString.CodedBuilder out = ByteString.newCodedBuilder(getSerializedSize()); + writeTo(out.getCodedOutput()); + return out.build(); + } catch (IOException e) { + throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e); + } + } + + public byte[] toByteArray() { + try { + final byte[] result = new byte[getSerializedSize()]; + final CodedOutputStream output = CodedOutputStream.newInstance(result); + writeTo(output); + output.checkNoSpaceLeft(); + return result; + } catch (IOException e) { + throw new RuntimeException(getSerializingExceptionMessage("byte array"), e); + } + } + + public void writeTo(final OutputStream output) throws IOException { + final int bufferSize = CodedOutputStream.computePreferredBufferSize(getSerializedSize()); + final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize); + writeTo(codedOutput); + codedOutput.flush(); + } + + public void writeDelimitedTo(final OutputStream output) throws IOException { + final int serialized = getSerializedSize(); + final int bufferSize = + CodedOutputStream.computePreferredBufferSize( + CodedOutputStream.computeUInt32SizeNoTag(serialized) + serialized); + final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize); + codedOutput.writeUInt32NoTag(serialized); + writeTo(codedOutput); + codedOutput.flush(); + } + + int getSerializedSize( + Schema schema) { + int memoizedSerializedSize = getMemoizedSerializedSize(); + if (memoizedSerializedSize == -1) { + memoizedSerializedSize = schema.getSerializedSize(this); + setMemoizedSerializedSize(memoizedSerializedSize); + } + return memoizedSerializedSize; + } + + private String getSerializingExceptionMessage(String target) { + return "Serializing " + + getClass().getName() + + " to a " + + target + + " threw an IOException (should never happen)."; + } + + protected static void checkByteStringIsUtf8(ByteString byteString) + throws IllegalArgumentException { + if (!byteString.isValidUtf8()) { + throw new IllegalArgumentException("Byte string is not UTF-8."); + } + } + + /** Interface for an enum which signifies which field in a {@code oneof} was specified. */ + protected interface InternalOneOfEnum { + /** + * Retrieves the field number of the field which was set in this {@code oneof}, or {@code 0} if + * none were. + */ + int getNumber(); + } + + /** + * Interface for the parent of a Builder that allows the builder to communicate invalidations back + * to the parent for use when using nested builders. + */ + protected interface BuilderParent extends Message.BuilderParent{ + + /** + * A builder becomes dirty whenever a field is modified -- including fields in nested builders + * -- and becomes clean when build() is called. Thus, when a builder becomes dirty, all its + * parents become dirty as well, and when it becomes clean, all its children become clean. The + * dirtiness state is used to invalidate certain cached values. + * + *

To this end, a builder calls markDirty() on its parent whenever it transitions from clean + * to dirty. The parent must propagate this call to its own parent, unless it was already dirty, + * in which case the grandparent must necessarily already be dirty as well. The parent can only + * transition back to "clean" after calling build() on all children. + */ + void markDirty(); + } + + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + protected int memoizedSize = -1; + + int getMemoizedSerializedSize() { + return memoizedSize; + } + + void setMemoizedSerializedSize(int size) { + memoizedSize = size; + } + + @Override + public boolean equals(final Object other) { + if (other == this) { + return true; + } + if (!(other instanceof Message)) { + return false; + } + final Message otherMessage = (Message) other; + if (getDescriptorForType() != otherMessage.getDescriptorForType()) { + return false; + } + return compareFields(getAllFields(), otherMessage.getAllFields()) + && getUnknownFields().equals(otherMessage.getUnknownFields()); + } + + @Override + public int hashCode() { + int hash = memoizedHashCode; + if (hash == 0) { + hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = hashFields(hash, getAllFields()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + } + return hash; + } + + private static ByteString toByteString(Object value) { + if (value instanceof byte[]) { + return ByteString.copyFrom((byte[]) value); + } else { + return (ByteString) value; + } + } + + /** + * Compares two bytes fields. The parameters must be either a byte array or a ByteString object. + * They can be of different type though. + */ + private static boolean compareBytes(Object a, Object b) { + if (a instanceof byte[] && b instanceof byte[]) { + return Arrays.equals((byte[]) a, (byte[]) b); + } + return toByteString(a).equals(toByteString(b)); + } + + /** Converts a list of MapEntry messages into a Map used for equals() and hashCode(). */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static Map convertMapEntryListToMap(List list) { + if (list.isEmpty()) { + return Collections.emptyMap(); + } + Map result = new HashMap<>(); + Iterator iterator = list.iterator(); + Message entry = (Message) iterator.next(); + Descriptor descriptor = entry.getDescriptorForType(); + FieldDescriptor key = descriptor.findFieldByName("key"); + FieldDescriptor value = descriptor.findFieldByName("value"); + Object fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + while (iterator.hasNext()) { + entry = (Message) iterator.next(); + fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + } + return result; + } + + /** Compares two map fields. The parameters must be a list of MapEntry messages. */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static boolean compareMapField(Object a, Object b) { + Map ma = convertMapEntryListToMap((List) a); + Map mb = convertMapEntryListToMap((List) b); + return MapFieldLite.equals(ma, mb); + } + + /** + * Compares two sets of fields. This method is used to implement {@link + * AbstractMessage#equals(Object)} and {@link AbstractMutableMessage#equals(Object)}. It takes + * special care of bytes fields because immutable messages and mutable messages use different Java + * type to represent a bytes field and this method should be able to compare immutable messages, + * mutable messages and also an immutable message to a mutable message. + */ + static boolean compareFields(Map a, Map b) { + if (a.size() != b.size()) { + return false; + } + for (FieldDescriptor descriptor : a.keySet()) { + if (!b.containsKey(descriptor)) { + return false; + } + Object value1 = a.get(descriptor); + Object value2 = b.get(descriptor); + if (descriptor.getType() == FieldDescriptor.Type.BYTES) { + if (descriptor.isRepeated()) { + List list1 = (List) value1; + List list2 = (List) value2; + if (list1.size() != list2.size()) { + return false; + } + for (int i = 0; i < list1.size(); i++) { + if (!compareBytes(list1.get(i), list2.get(i))) { + return false; + } + } + } else { + // Compares a singular bytes field. + if (!compareBytes(value1, value2)) { + return false; + } + } + } else if (descriptor.isMapField()) { + if (!compareMapField(value1, value2)) { + return false; + } + } else { + // Compare non-bytes fields. + if (!value1.equals(value2)) { + return false; + } + } + } + return true; + } + + /** Calculates the hash code of a map field. {@code value} must be a list of MapEntry messages. */ + @SuppressWarnings("unchecked") + private static int hashMapField(Object value) { + return MapFieldLite.calculateHashCodeForMap(convertMapEntryListToMap((List) value)); + } + + /** Get a hash code for given fields and values, using the given seed. */ + @SuppressWarnings("unchecked") + protected static int hashFields(int hash, Map map) { + for (Map.Entry entry : map.entrySet()) { + FieldDescriptor field = entry.getKey(); + Object value = entry.getValue(); + hash = (37 * hash) + field.getNumber(); + if (field.isMapField()) { + hash = (53 * hash) + hashMapField(value); + } else if (field.getType() != FieldDescriptor.Type.ENUM) { + hash = (53 * hash) + value.hashCode(); + } else if (field.isRepeated()) { + List list = (List) value; + hash = (53 * hash) + Internal.hashEnumList(list); + } else { + hash = (53 * hash) + Internal.hashEnum((Internal.EnumLite) value); + } + } + return hash; + } + +// /** +// * Package private helper method for AbstractParser to create UninitializedMessageException with +// * missing field information. +// */ +// UninitializedMessageException newUninitializedMessageException() { +// return AbstractMessage.Builder.newUninitializedMessageException(this); +// } + + /** TODO: Remove this unnecessary intermediate implementation of this method. */ + @Override + public Parser getParserForType() { + throw new UnsupportedOperationException("This is supposed to be overridden by subclasses."); + } + + /** + * TODO: Stop using SingleFieldBuilder and remove this setting + * + * @see #setAlwaysUseFieldBuildersForTesting(boolean) + */ + static void enableAlwaysUseFieldBuildersForTesting() { + setAlwaysUseFieldBuildersForTesting(true); + } + + /** + * For testing. Allows a test to disable/re-enable the optimization that avoids using field + * builders for nested messages until they are requested. By disabling this optimization, existing + * tests can be reused to test the field builders. See {@link RepeatedFieldBuilder} and {@link + * SingleFieldBuilder}. + * + *

TODO: Stop using SingleFieldBuilder and remove this setting + */ + static void setAlwaysUseFieldBuildersForTesting(boolean useBuilders) { + alwaysUseFieldBuilders = useBuilders; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + /** + * TODO: This method should be removed. It enables parsing directly into an + * "immutable" message. Have to leave it for now to support old gencode. + * + * @deprecated use newBuilder().mergeFrom() instead + */ + @Deprecated + protected void mergeFromAndMakeImmutableInternal( + CodedInputStream input, ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + Schema schema = Protobuf.getInstance().schemaFor(this); + try { + schema.mergeFrom(this, CodedInputStreamReader.forCodedInput(input), extensionRegistry); + } catch (InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (IOException e) { + throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } + schema.makeImmutable(this); + } + + /** + * Internal helper to return a modifiable map containing all the fields. The returned Map is + * modifiable so that the caller can add additional extension fields to implement {@link + * #getAllFields()}. + * + * @param getBytesForString whether to generate ByteString for string fields + */ + private Map getAllFieldsMutable(boolean getBytesForString) { + final TreeMap result = new TreeMap<>(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + if (getBytesForString && field.getJavaType() == FieldDescriptor.JavaType.STRING) { + result.put(field, getFieldRaw(field)); + } else { + result.put(field, getField(field)); + } + } + return result; + } + + // TODO: compute this at {@code build()} time in the Builder class. + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + + return true; + } + + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString= */ false)); + } + + /** + * Returns a collection of all the fields in this message which are set and their corresponding + * values. A singular ("required" or "optional") field is set iff hasField() returns true for that + * field. A "repeated" field is set iff getRepeatedFieldCount() is greater than zero. The values + * are exactly what would be returned by calling {@link #getFieldRaw(FieldDescriptor)} + * for each field. The map is guaranteed to be a sorted map, so iterating over it will return + * fields in order by field number. + */ + Map getAllFieldsRaw() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString= */ true)); + } + + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + public Object getField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).get(this); + } + + /** + * Obtains the value of the given field, or the default value if it is not set. For primitive + * fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the + * value is returned. For embedded message fields, the sub-message is returned. For repeated + * fields, a java.util.List is returned. For present string fields, a ByteString is returned + * representing the bytes that the field contains. + */ + Object getFieldRaw(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRaw(this); + } + + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + // TODO: This method should be final. + public UnknownFieldSet getUnknownFields() { + return unknownFields; + } + + // TODO: This should go away when Schema classes cannot modify immutable + // GeneratedMessageV3 objects anymore. + void setUnknownFields(UnknownFieldSet unknownFields) { + this.unknownFields = unknownFields; + } + + /** + * Called by subclasses to parse an unknown field. + * + *

TODO remove this method + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + if (input.shouldDiscardUnknownFields()) { + return input.skipField(tag); + } + return unknownFields.mergeFieldFrom(tag, input); + } + + /** + * Delegates to parseUnknownField. This method is obsolete, but we must retain it for + * compatibility with older generated code. + * + *

TODO remove this method + */ + protected boolean parseUnknownFieldProto3( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return parseUnknownField(input, unknownFields, extensionRegistry, tag); + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseWithIOException(Parser parser, InputStream input) + throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseWithIOException( + Parser parser, CodedInputStream input) throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseWithIOException( + Parser parser, CodedInputStream input, ExtensionRegistryLite extensions) + throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input) throws IOException { + try { + return parser.parseDelimitedFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseDelimitedFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static boolean canUseUnsafe() { + return UnsafeUtil.hasUnsafeArrayOperations() && UnsafeUtil.hasUnsafeByteBufferOperations(); + } + + protected static IntList emptyIntList() { + return IntArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static IntList newIntList() { + return new IntArrayList(); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static IntList mutableCopy(IntList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static LongList mutableCopy(LongList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static FloatList mutableCopy(FloatList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static DoubleList mutableCopy(DoubleList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static BooleanList mutableCopy(BooleanList list) { + return makeMutableCopy(list); + } + + protected static LongList emptyLongList() { + return LongArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static LongList newLongList() { + return new LongArrayList(); + } + + protected static FloatList emptyFloatList() { + return FloatArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static FloatList newFloatList() { + return new FloatArrayList(); + } + + protected static DoubleList emptyDoubleList() { + return DoubleArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static DoubleList newDoubleList() { + return new DoubleArrayList(); + } + + protected static BooleanList emptyBooleanList() { + return BooleanArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static BooleanList newBooleanList() { + return new BooleanArrayList(); + } + + protected static > ListT makeMutableCopy(ListT list) { + return makeMutableCopy(list, 0); + } + + @SuppressWarnings("unchecked") // Guaranteed by proto runtime. + protected static > ListT makeMutableCopy( + ListT list, int minCapacity) { + int size = list.size(); + if (minCapacity <= size) { + minCapacity = size * 2; + } + if (minCapacity <= 0) { + minCapacity = AbstractProtobufList.DEFAULT_CAPACITY; + } + + return (ListT) list.mutableCopyWithCapacity(minCapacity); + } + + @SuppressWarnings("unchecked") // The empty list can be safely cast + protected static ProtobufList emptyList(Class elementType) { + return (ProtobufList) ProtobufArrayList.emptyList(); + } + + public void writeTo(final CodedOutputStream output) throws IOException { + MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false); + } + + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) { + return size; + } + + memoizedSize = MessageReflection.getSerializedSize( + this, getAllFieldsRaw()); + return memoizedSize; + } + + /** + * This class is used to make a generated protected method inaccessible from user's code (e.g., + * the {@link #newInstance} method below). When this class is used as a parameter's type in a + * generated protected method, the method is visible to user's code in the same package, but since + * the constructor of this class is private to protobuf runtime, user's code can't obtain an + * instance of this class and as such can't actually make a method call on the protected method. + */ + protected static final class UnusedPrivateParameter { + static final UnusedPrivateParameter INSTANCE = new UnusedPrivateParameter(); + + private UnusedPrivateParameter() {} + } + + /** Creates a new instance of this message type. Overridden in the generated code. */ + @SuppressWarnings({"unused"}) + protected Object newInstance(UnusedPrivateParameter unused) { + throw new UnsupportedOperationException("This method must be overridden by the subclass."); + } + + /** + * Used by parsing constructors in generated classes. + * + *

TODO: remove unused method (extensions should be immutable after build) + */ + protected void makeExtensionsImmutable() { + // Noop for messages without extensions. + } + + /** TODO: remove this together with GeneratedMessageV3.BuilderParent. */ + protected abstract Message.Builder newBuilderForType(BuilderParent parent); + + /** TODO: generated class should implement this directly */ + public Message.Builder newBuilderForType(final Message.BuilderParent parent) { + return newBuilderForType( + new BuilderParent() { + @Override + public void markDirty() { + parent.markDirty(); + } + }); + } + + /** Builder class for {@link FlattenedGeneratedMessageV3}. */ + @SuppressWarnings("unchecked") + public abstract static class Builder> + implements Message.Builder { + + private BuilderParent builderParent; + + private BuilderParentImpl meAsParent; + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See GeneratedMessageV3.BuilderListener. + private boolean isClean; + + /** + * This field holds either an {@link UnknownFieldSet} or {@link UnknownFieldSet.Builder}. + * + *

We use an object because it should only be one or the other of those things at a time and + * Object is the only common base. This also saves space. + * + *

Conversions are lazy: if {@link #setUnknownFields} is called, this will contain {@link + * UnknownFieldSet}. If unknown fields are merged into this builder, the current {@link + * UnknownFieldSet} will be converted to a {@link UnknownFieldSet.Builder} and left that way + * until either {@link #setUnknownFields} or {@link #buildPartial} or {@link #build} is called. + */ + private Object unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance(); + + protected Builder() { + this(null); + } + + protected Builder(BuilderParent builderParent) { + this.builderParent = builderParent; + } + + static final class LimitedInputStream extends FilterInputStream { + private int limit; + + LimitedInputStream(InputStream in, int limit) { + super(in); + this.limit = limit; + } + + @Override + public int available() throws IOException { + return Math.min(super.available(), limit); + } + + @Override + public int read() throws IOException { + if (limit <= 0) { + return -1; + } + final int result = super.read(); + if (result >= 0) { + --limit; + } + return result; + } + + @Override + public int read(final byte[] b, final int off, int len) throws IOException { + if (limit <= 0) { + return -1; + } + len = Math.min(len, limit); + final int result = super.read(b, off, len); + if (result >= 0) { + limit -= result; + } + return result; + } + + @Override + public long skip(final long n) throws IOException { + // because we take the minimum of an int and a long, result is guaranteed to be + // less than or equal to Integer.MAX_INT so this cast is safe + int result = (int) super.skip(Math.min(n, limit)); + if (result >= 0) { + // if the superclass adheres to the contract for skip, this condition is always true + limit -= result; + } + return result; + } + } + + @Override + public boolean mergeDelimitedFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final int firstByte = input.read(); + if (firstByte == -1) { + return false; + } + final int size = CodedInputStream.readRawVarint32(firstByte, input); + final InputStream limitedInput = new LimitedInputStream(input, size); + mergeFrom(limitedInput, extensionRegistry); + return true; + } + + @Override + public boolean mergeDelimitedFrom(final InputStream input) throws IOException { + return mergeDelimitedFrom(input, ExtensionRegistryLite.getEmptyRegistry()); + } + + @Override + @SuppressWarnings("unchecked") // isInstance takes care of this + public BuilderT mergeFrom(final MessageLite other) { + if (!getDefaultInstanceForType().getClass().isInstance(other)) { + throw new IllegalArgumentException( + "mergeFrom(MessageLite) can only merge messages of the same type."); + } + + return internalMergeFrom(other); + } + + private String getReadingExceptionMessage(String target) { + return "Reading " + + getClass().getName() + + " from a " + + target + + " threw an IOException (should never happen)."; + } + + // We check nulls as we iterate to avoid iterating over values twice. + private static void addAllCheckingNulls(Iterable values, List list) { + if (list instanceof ArrayList && values instanceof Collection) { + ((ArrayList) list).ensureCapacity(list.size() + ((Collection) values).size()); + } + int begin = list.size(); + for (T value : values) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (list.size() - begin) + " is null."; + for (int i = list.size() - 1; i >= begin; i--) { + list.remove(i); + } + throw new NullPointerException(message); + } + list.add(value); + } + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + MessageLite message) { + return new UninitializedMessageException(message); + } + + // For binary compatibility. + @Deprecated + protected static void addAll(final Iterable values, final Collection list) { + addAll(values, (List) list); + } + + /** + * Adds the {@code values} to the {@code list}. This is a helper method used by generated code. + * Users should ignore it. + * + * @throws NullPointerException if {@code values} or any of the elements of {@code values} is + * null. + */ + protected static void addAll(final Iterable values, final List list) { + checkNotNull(values); + if (values instanceof LazyStringList) { + // For StringOrByteStringLists, check the underlying elements to avoid + // forcing conversions of ByteStrings to Strings. + // TODO: Could we just prohibit nulls in all protobuf lists and get rid of this? Is + // if even possible to hit this condition as all protobuf methods check for null first, + // right? + List lazyValues = ((LazyStringList) values).getUnderlyingElements(); + LazyStringList lazyList = (LazyStringList) list; + int begin = list.size(); + for (Object value : lazyValues) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (lazyList.size() - begin) + " is null."; + for (int i = lazyList.size() - 1; i >= begin; i--) { + lazyList.remove(i); + } + throw new NullPointerException(message); + } + if (value instanceof ByteString) { + lazyList.add((ByteString) value); + } else { + lazyList.add((String) value); + } + } + } else { + if (values instanceof PrimitiveNonBoxingCollection) { + list.addAll((Collection) values); + } else { + addAllCheckingNulls(values, list); + } + } + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + protected BuilderT internalMergeFrom(MessageLite other) { + return mergeFrom((Message) other); + } + + @Override + public BuilderT mergeFrom(final Message other) { + return mergeFrom(other, other.getAllFields()); + } + + BuilderT mergeFrom(final Message other, Map allFields) { + if (other.getDescriptorForType() != getDescriptorForType()) { + throw new IllegalArgumentException( + "mergeFrom(Message) can only merge messages of the same type."); + } + + // Note: We don't attempt to verify that other's fields have valid + // types. Doing so would be a losing battle. We'd have to verify + // all sub-messages as well, and we'd have to make copies of all of + // them to insure that they don't change after verification (since + // the Message interface itself cannot enforce immutability of + // implementations). + + for (final Map.Entry entry : allFields.entrySet()) { + final FieldDescriptor field = entry.getKey(); + if (field.isRepeated()) { + for (final Object element : (List) entry.getValue()) { + addRepeatedField(field, element); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + final Message existingValue = (Message) getField(field); + if (existingValue == existingValue.getDefaultInstanceForType()) { + setField(field, entry.getValue()); + } else { + setField( + field, + existingValue + .newBuilderForType() + .mergeFrom(existingValue) + .mergeFrom((Message) entry.getValue()) + .build()); + } + } else { + setField(field, entry.getValue()); + } + } + + mergeUnknownFields(other.getUnknownFields()); + + return (BuilderT) this; + } + + @Override + public BuilderT mergeFrom(final CodedInputStream input) throws IOException { + return mergeFrom(input, ExtensionRegistry.getEmptyRegistry()); + } + + @Override + public BuilderT mergeFrom( + final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) + throws IOException { + boolean discardUnknown = input.shouldDiscardUnknownFields(); + final UnknownFieldSet.Builder unknownFields = + discardUnknown ? null : getUnknownFieldSetBuilder(); + MessageReflection.mergeMessageFrom(this, unknownFields, input, extensionRegistry); + if (unknownFields != null) { + setUnknownFieldSetBuilder(unknownFields); + } + return (BuilderT) this; + } + + @Override + public String toString() { + return TextFormatInternal.printer().printToString(this); + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + Message message) { + return new UninitializedMessageException(MessageReflection.findMissingFields(message)); + } + + // =============================================================== + // The following definitions seem to be required in order to make javac + // not produce weird errors like: + // + // java/com/google/protobuf/DynamicMessage.java:203: types + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> and + // com.google.protobuf.AbstractMessage.Builder< + // com.google.protobuf.DynamicMessage.Builder> are incompatible; both + // define mergeFrom(com.google.protobuf.ByteString), but with unrelated + // return types. + // + // Strangely, these lines are only needed if javac is invoked separately + // on AbstractMessage.java and AbstractMessageLite.java. If javac is + // invoked on both simultaneously, it works. (Or maybe the important + // point is whether or not DynamicMessage.java is compiled together with + // AbstractMessageLite.java -- not sure.) I suspect this is a compiler + // bug. + + public BuilderT mergeFrom(final ByteString data) throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input); + input.checkLastTagWas(0); + return (BuilderT) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public BuilderT mergeFrom( + final ByteString data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (BuilderT) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public BuilderT mergeFrom(final byte[] data) throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length); + } + + public BuilderT mergeFrom(final byte[] data, final int off, final int len) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input); + input.checkLastTagWas(0); + return (BuilderT) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public BuilderT mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length, extensionRegistry); + } + + public BuilderT mergeFrom( + final byte[] data, + final int off, + final int len, + final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (BuilderT) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public BuilderT mergeFrom(final InputStream input) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput); + codedInput.checkLastTagWas(0); + return (BuilderT) this; + } + + public BuilderT mergeFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput, extensionRegistry); + codedInput.checkLastTagWas(0); + return (BuilderT) this; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashLong(long n) { + return (int) (n ^ (n >>> 32)); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashBoolean(boolean b) { + return b ? 1231 : 1237; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnum(Internal.EnumLite e) { + return e.getNumber(); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnumList(List list) { + int hash = 1; + for (Internal.EnumLite e : list) { + hash = 31 * hash + hashEnum(e); + } + return hash; + } + + public void dispose() { + builderParent = null; + } + + /** Called by the subclass when a message is built. */ + protected void onBuilt() { + if (builderParent != null) { + markClean(); + } + } + + /** + * Called by the subclass or a builder to notify us that a message was built and may be cached + * and therefore invalidations are needed. + */ + public void markClean() { + this.isClean = true; + } + + /** + * Gets whether invalidations are needed + * + * @return whether invalidations are needed + */ + protected boolean isClean() { + return isClean; + } + + @Override + public BuilderT clone() { + BuilderT builder = (BuilderT) getDefaultInstanceForType().newBuilderForType(); + builder.mergeFrom(buildPartial()); + return builder; + } + + /** + * Called by the initialization and clear code paths to allow subclasses to reset any of their + * builtin fields back to the initial values. + */ + @Override + public BuilderT clear() { + unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance(); + onChanged(); + return (BuilderT) this; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + @Override + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + @Override + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable()); + } + + /** Internal helper which returns a mutable map. */ + private Map getAllFieldsMutable() { + final TreeMap result = new TreeMap<>(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + result.put(field, getField(field)); + } + return result; + } + + @Override + public Message.Builder newBuilderForField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).newBuilder(); + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getBuilder(this); + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + return internalGetFieldAccessorTable().getField(field).getRepeatedBuilder(this, index); + } + + @Override + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + @Override + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + @Override + public Object getField(final FieldDescriptor field) { + Object object = internalGetFieldAccessorTable().getField(field).get(this); + if (field.isRepeated()) { + // The underlying list object is still modifiable at this point. + // Make sure not to expose the modifiable list to the caller. + return Collections.unmodifiableList((List) object); + } else { + return object; + } + } + + @Override + public BuilderT setField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).set(this, value); + return (BuilderT) this; + } + + @Override + public BuilderT clearField(final FieldDescriptor field) { + internalGetFieldAccessorTable().getField(field).clear(this); + return (BuilderT) this; + } + + @Override + public BuilderT clearOneof(final OneofDescriptor oneof) { + internalGetFieldAccessorTable().getOneof(oneof).clear(this); + return (BuilderT) this; + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + @Override + public BuilderT setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + internalGetFieldAccessorTable().getField(field).setRepeated(this, index, value); + return (BuilderT) this; + } + + @Override + public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).addRepeated(this, value); + return (BuilderT) this; + } + + private BuilderT setUnknownFieldsInternal(final UnknownFieldSet unknownFields) { + unknownFieldsOrBuilder = unknownFields; + onChanged(); + return (BuilderT) this; + } + + @Override + public BuilderT setUnknownFields(final UnknownFieldSet unknownFields) { + return setUnknownFieldsInternal(unknownFields); + } + + /** + * This method is obsolete, but we must retain it for compatibility with older generated code. + */ + protected BuilderT setUnknownFieldsProto3(final UnknownFieldSet unknownFields) { + return setUnknownFieldsInternal(unknownFields); + } + + @Override + public BuilderT mergeUnknownFields(final UnknownFieldSet unknownFields) { + if (UnknownFieldSet.getDefaultInstance().equals(unknownFields)) { + return (BuilderT) this; + } + + if (UnknownFieldSet.getDefaultInstance().equals(unknownFieldsOrBuilder)) { + unknownFieldsOrBuilder = unknownFields; + onChanged(); + return (BuilderT) this; + } + + getUnknownFieldSetBuilder().mergeFrom(unknownFields); + onChanged(); + return (BuilderT) this; + } + + @Override + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + return true; + } + + @Override + public final UnknownFieldSet getUnknownFields() { + if (unknownFieldsOrBuilder instanceof UnknownFieldSet) { + return (UnknownFieldSet) unknownFieldsOrBuilder; + } else { + return ((UnknownFieldSet.Builder) unknownFieldsOrBuilder).buildPartial(); + } + } + + /** + * Called by generated subclasses to parse an unknown field. + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) + throws IOException { + if (input.shouldDiscardUnknownFields()) { + return input.skipField(tag); + } + return getUnknownFieldSetBuilder().mergeFieldFrom(tag, input); + } + + /** Called by generated subclasses to add to the unknown field set. */ + protected final void mergeUnknownLengthDelimitedField(int number, ByteString bytes) { + getUnknownFieldSetBuilder().mergeLengthDelimitedField(number, bytes); + } + + /** Called by generated subclasses to add to the unknown field set. */ + protected final void mergeUnknownVarintField(int number, int value) { + getUnknownFieldSetBuilder().mergeVarintField(number, value); + } + + protected UnknownFieldSet.Builder getUnknownFieldSetBuilder() { + if (unknownFieldsOrBuilder instanceof UnknownFieldSet) { + unknownFieldsOrBuilder = ((UnknownFieldSet) unknownFieldsOrBuilder).toBuilder(); + } + onChanged(); + return (UnknownFieldSet.Builder) unknownFieldsOrBuilder; + } + + protected void setUnknownFieldSetBuilder(UnknownFieldSet.Builder builder) { + unknownFieldsOrBuilder = builder; + onChanged(); + } + + /** + * Implementation of {@link BuilderParent} for giving to our children. This small inner class + * makes it so we don't publicly expose the BuilderParent methods. + */ + private class BuilderParentImpl implements BuilderParent { + + @Override + public void markDirty() { + onChanged(); + } + } + + /** + * Gets the {@link BuilderParent} for giving to our children. + * + * @return The builder parent for our children. + */ + protected BuilderParent getParentForChildren() { + if (meAsParent == null) { + meAsParent = new BuilderParentImpl(); + } + return meAsParent; + } + + /** + * Called when a builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + protected final void onChanged() { + if (isClean && builderParent != null) { + builderParent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but + * the generated API only allows us to access it as a map. This method returns the underlying + * map field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapFieldReflectionAccessor internalGetMapFieldReflection(int fieldNumber) { + return internalGetMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + + /** Like {@link #internalGetMapFieldReflection} but return a mutable version. */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int fieldNumber) { + return internalGetMutableMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMutableMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + } + + // ================================================================= + // Extensions-related stuff + + /** Extends {@link MessageOrBuilder} with extension-related functions. */ + public interface ExtendableMessageOrBuilder> + extends MessageOrBuilder { + // Re-define for return type covariance. + @Override + Message getDefaultInstanceForType(); + + /** Check if a singular extension is present. */ + boolean hasExtension(ExtensionLite extension); + + /** Get the number of elements in a repeated extension. */ + int getExtensionCount(ExtensionLite> extension); + + /** Get the value of an extension. */ + T getExtension(ExtensionLite extension); + + /** Get one element of a repeated extension. */ + T getExtension(ExtensionLite> extension, int index); + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + boolean hasExtension( + Extension extension); + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + boolean hasExtension( + GeneratedExtension extension); + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + int getExtensionCount( + Extension> extension); + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + int getExtensionCount( + GeneratedExtension> extension); + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + Extension extension); + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + GeneratedExtension extension); + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + Extension> extension, + int index); + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + GeneratedExtension> extension, + int index); + } + + /** + * Generated message classes for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "has", "get", and "getCount" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo = getFoo();
+   * int i = foo.getExtension(MyProto.bar);
+   * 
+ * + *

See also {@link ExtendableBuilder}. + */ + public abstract static class ExtendableMessage> + extends FlattenedGeneratedMessageV3 implements ExtendableMessageOrBuilder { + + private static final long serialVersionUID = 1L; + + private final FieldSet extensions; + + protected ExtendableMessage() { + this.extensions = FieldSet.newFieldSet(); + } + + protected ExtendableMessage(ExtendableBuilder builder) { + super(builder); + this.extensions = builder.buildExtensions(); + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + @SuppressWarnings("unchecked") + public final T getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (T) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (T) extension.getMessageDefaultInstance(); + } else { + return (T) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (T) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + @SuppressWarnings("unchecked") + public final T getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + return (T) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension( + final GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions.isInitialized(); + } + + // TODO: compute this in the builder at {@code build()} time. + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + // TODO: remove mutating method from immutable type + @Override + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return MessageReflection.mergeFieldFrom( + input, + input.shouldDiscardUnknownFields() ? null : unknownFields, + extensionRegistry, + getDescriptorForType(), + new MessageReflection.ExtensionAdapter(extensions), + tag); + } + + /** + * Delegates to parseUnknownField. This method is obsolete, but we must retain it for + * compatibility with older generated code. + * + *

TODO: remove mutating method from immutable type + */ + @Override + protected boolean parseUnknownFieldProto3( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return parseUnknownField(input, unknownFields, extensionRegistry, tag); + } + + /** + * Used by parsing constructors in generated classes. + * + *

TODO: remove unused method (extensions should be immutable after build) + */ + @Override + protected void makeExtensionsImmutable() { + extensions.makeImmutable(); + } + + /** + * Used by subclasses to serialize extensions. Extension ranges may be interleaved with field + * numbers, but we must write them in canonical (sorted by field number) order. ExtensionWriter + * helps us write individual ranges of extensions at once. + */ + protected class ExtensionWriter { + // Imagine how much simpler this code would be if Java iterators had + // a way to get the next element without advancing the iterator. + + private final Iterator> iter = extensions.iterator(); + private Map.Entry next; + private final boolean messageSetWireFormat; + + private ExtensionWriter(final boolean messageSetWireFormat) { + if (iter.hasNext()) { + next = iter.next(); + } + this.messageSetWireFormat = messageSetWireFormat; + } + + public void writeUntil(final int end, final CodedOutputStream output) throws IOException { + while (next != null && next.getKey().getNumber() < end) { + FieldDescriptor descriptor = next.getKey(); + if (messageSetWireFormat + && descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE + && !descriptor.isRepeated()) { + if (next instanceof LazyField.LazyEntry) { + output.writeRawMessageSetExtension( + descriptor.getNumber(), + ((LazyField.LazyEntry) next).getField().toByteString()); + } else { + output.writeMessageSetExtension(descriptor.getNumber(), (Message) next.getValue()); + } + } else { + // TODO: Taken care of following code, it may cause + // problem when we use LazyField for normal fields/extensions. + // Due to the optional field can be duplicated at the end of + // serialized bytes, which will make the serialized size change + // after lazy field parsed. So when we use LazyField globally, + // we need to change the following write method to write cached + // bytes directly rather than write the parsed message. + FieldSet.writeField(descriptor, next.getValue(), output); + } + if (iter.hasNext()) { + next = iter.next(); + } else { + next = null; + } + } + } + } + + protected ExtensionWriter newExtensionWriter() { + return new ExtensionWriter(false); + } + + protected ExtensionWriter newMessageSetExtensionWriter() { + return new ExtensionWriter(true); + } + + /** Called by subclasses to compute the size of extensions. */ + protected int extensionsSerializedSize() { + return extensions.getSerializedSize(); + } + + protected int extensionsSerializedSizeAsMessageSet() { + return extensions.getMessageSetSerializedSize(); + } + + // --------------------------------------------------------------- + // Reflection + + protected Map getExtensionFields() { + return extensions.getAllFields(); + } + + @Override + public Map getAllFields() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString= */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public Map getAllFieldsRaw() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString= */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions.getField(field); + if (value == null) { + if (field.isRepeated()) { + return Collections.emptyList(); + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + /** + * Type used to represent generated extensions. The protocol compiler generates a static singleton + * instance of this class for each extension. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then, {@code MyProto.Foo.bar} has type {@code GeneratedExtension}. + * + *

In general, users should ignore the details of this type, and simply use these static + * singletons as parameters to the extension accessors defined in {@link GeneratedMessage.ExtendableMessage} and + * {@link GeneratedMessage.ExtendableBuilder}. + */ + public static class GeneratedExtension + extends Extension { + // TODO: Find ways to avoid using Java reflection within this + // class. Also try to avoid suppressing unchecked warnings. + + // We can't always initialize the descriptor of a GeneratedExtension when + // we first construct it due to initialization order difficulties (namely, + // the descriptor may not have been constructed yet, since it is often + // constructed by the initializer of a separate module). + // + // In the case of nested extensions, we initialize the + // ExtensionDescriptorRetriever with an instance that uses the scoping + // Message's default instance to retrieve the extension's descriptor. + // + // In the case of non-nested extensions, we initialize the + // ExtensionDescriptorRetriever to null and rely on the outer class's static + // initializer to call internalInit() after the descriptor has been parsed. + GeneratedExtension( + ExtensionDescriptorRetriever descriptorRetriever, + Class singularType, + Message messageDefaultInstance, + ExtensionType extensionType) { + if (Message.class.isAssignableFrom(singularType) + && !singularType.isInstance(messageDefaultInstance)) { + throw new IllegalArgumentException( + "Bad messageDefaultInstance for " + singularType.getName()); + } + this.descriptorRetriever = descriptorRetriever; + this.singularType = singularType; + this.messageDefaultInstance = messageDefaultInstance; + + if (ProtocolMessageEnum.class.isAssignableFrom(singularType)) { + this.enumValueOf = getMethodOrDie(singularType, "valueOf", EnumValueDescriptor.class); + this.enumGetValueDescriptor = getMethodOrDie(singularType, "getValueDescriptor"); + } else { + this.enumValueOf = null; + this.enumGetValueDescriptor = null; + } + this.extensionType = extensionType; + } + + /** For use by generated code only. */ + public void internalInit(final FieldDescriptor descriptor) { + if (descriptorRetriever != null) { + throw new IllegalStateException("Already initialized."); + } + descriptorRetriever = + new ExtensionDescriptorRetriever() { + @Override + public FieldDescriptor getDescriptor() { + return descriptor; + } + }; + } + + /** + * Gets the descriptor for an extension. The implementation depends on whether the extension is + * scoped in the top level of a file or scoped in a Message. + */ + static interface ExtensionDescriptorRetriever { + FieldDescriptor getDescriptor(); + } + + private ExtensionDescriptorRetriever descriptorRetriever; + private final Class singularType; + private final Message messageDefaultInstance; + private final Method enumValueOf; + private final Method enumGetValueDescriptor; + private final ExtensionType extensionType; + + @Override + public FieldDescriptor getDescriptor() { + if (descriptorRetriever == null) { + throw new IllegalStateException("getDescriptor() called before internalInit()"); + } + return descriptorRetriever.getDescriptor(); + } + + /** + * If the extension is an embedded message or group, returns the default instance of the + * message. + */ + @Override + public Message getMessageDefaultInstance() { + return messageDefaultInstance; + } + + @Override + protected ExtensionType getExtensionType() { + return extensionType; + } + + /** + * Convert from the type used by the reflection accessors to the type used by native accessors. + * E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors + * use the generated enum type. + */ + @Override + @SuppressWarnings("unchecked") + protected Object fromReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + if (descriptor.isRepeated()) { + if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE + || descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) { + // Must convert the whole list. + final List result = new ArrayList(); + for (final Object element : (List) value) { + result.add(singularFromReflectionType(element)); + } + return result; + } else { + return value; + } + } else { + return singularFromReflectionType(value); + } + } + + /** + * Like {@link #fromReflectionType(Object)}, but if the type is a repeated type, this converts a + * single element. + */ + @Override + protected Object singularFromReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + switch (descriptor.getJavaType()) { + case MESSAGE: + if (singularType.isInstance(value)) { + return value; + } else { + return messageDefaultInstance.newBuilderForType().mergeFrom((Message) value).build(); + } + case ENUM: + return invokeOrDie(enumValueOf, null, (EnumValueDescriptor) value); + default: + return value; + } + } + + /** + * Convert from the type used by the native accessors to the type used by reflection accessors. + * E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors + * use the generated enum type. + */ + @Override + @SuppressWarnings("unchecked") + protected Object toReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + if (descriptor.isRepeated()) { + if (descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) { + // Must convert the whole list. + final List result = new ArrayList(); + for (final Object element : (List) value) { + result.add(singularToReflectionType(element)); + } + return result; + } else { + return value; + } + } else { + return singularToReflectionType(value); + } + } + + /** + * Like {@link #toReflectionType(Object)}, but if the type is a repeated type, this converts a + * single element. + */ + @Override + protected Object singularToReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + switch (descriptor.getJavaType()) { + case ENUM: + return invokeOrDie(enumGetValueDescriptor, value); + default: + return value; + } + } + + @Override + public int getNumber() { + return getDescriptor().getNumber(); + } + + @Override + public WireFormat.FieldType getLiteType() { + return getDescriptor().getLiteType(); + } + + @Override + public boolean isRepeated() { + return getDescriptor().isRepeated(); + } + + @Override + @SuppressWarnings("unchecked") + public Type getDefaultValue() { + if (isRepeated()) { + return (Type) Collections.emptyList(); + } + if (getDescriptor().getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (Type) messageDefaultInstance; + } + return (Type) singularFromReflectionType(getDescriptor().getDefaultValue()); + } + } + + + /** + * Generated message builders for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "get", "set", and "add" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo =
+   *   MyProto.Foo.newBuilder()
+   *     .setExtension(MyProto.bar, 123)
+   *     .build();
+   * 
+ * + *

See also {@link ExtendableMessage}. + */ + @SuppressWarnings("unchecked") + public abstract static class ExtendableBuilder< + MessageT extends ExtendableMessage, + BuilderT extends ExtendableBuilder> + extends Builder implements ExtendableMessageOrBuilder { + + private FieldSet.Builder extensions; + + protected ExtendableBuilder() {} + + protected ExtendableBuilder(BuilderParent parent) { + super(parent); + } + + // For immutable message conversion. + void internalSetExtensionSet(FieldSet extensions) { + this.extensions = FieldSet.Builder.fromFieldSet(extensions); + } + + @Override + public BuilderT clear() { + extensions = null; + return super.clear(); + } + + private void ensureExtensionsIsMutable() { + if (extensions == null) { + extensions = FieldSet.newBuilder(); + } + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions != null && extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + public final T getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions == null ? null : extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (T) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (T) extension.getMessageDefaultInstance(); + } else { + return (T) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (T) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + public final T getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } + return (T) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** Set the value of an extension. */ + public final BuilderT setExtension( + final ExtensionLite extensionLite, final T value) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setField(descriptor, extension.toReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Set the value of one element of a repeated extension. */ + public final BuilderT setExtension( + final ExtensionLite> extensionLite, final int index, final T value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setRepeatedField(descriptor, index, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Append a value to a repeated extension. */ + public final BuilderT addExtension( + final ExtensionLite> extensionLite, final T value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.addRepeatedField(descriptor, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Clear an extension. */ + public final BuilderT clearExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + extensions.clearField(extension.getDescriptor()); + onChanged(); + return (BuilderT) this; + } + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension( + final FlattenedGeneratedMessageV3.GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final FlattenedGeneratedMessageV3.GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Set the value of an extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT setExtension( + final Extension extension, final T value) { + return setExtension((ExtensionLite) extension, value); + } + /** + * Set the value of an extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT setExtension( + final GeneratedExtension extension, final T value) { + return setExtension((ExtensionLite) extension, value); + } + /** + * Set the value of one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT setExtension( + final Extension> extension, + final int index, final T value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** + * Set the value of one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT setExtension( + final GeneratedExtension> extension, + final int index, final T value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** + * Append a value to a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT addExtension( + final Extension> extension, final T value) { + return addExtension((ExtensionLite>) extension, value); + } + /** + * Append a value to a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT addExtension( + final GeneratedExtension> extension, final T value) { + return addExtension((ExtensionLite>) extension, value); + } + /** + * Clear an extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT clearExtension( + final Extension extension) { + return clearExtension((ExtensionLite) extension); + } + /** + * Clears an extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT clearExtension( + final GeneratedExtension extension) { + return clearExtension((ExtensionLite) extension); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions == null || extensions.isInitialized(); + } + + /** + * Called by the build code path to create a copy of the extensions for building the message. + */ + private FieldSet buildExtensions() { + return extensions == null + ? (FieldSet) FieldSet.emptySet() + : extensions.buildPartial(); + } + + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + // --------------------------------------------------------------- + // Reflection + + @Override + public Map getAllFields() { + final Map result = super.getAllFieldsMutable(); + if (extensions != null) { + result.putAll(extensions.getAllFields()); + } + return Collections.unmodifiableMap(result); + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions == null ? null : extensions.getField(field); + if (value == null) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on a non-Message type."); + } + ensureExtensionsIsMutable(); + final Object value = extensions.getFieldAllowBuilders(field); + if (value == null) { + Message.Builder builder = DynamicMessage.newBuilder(field.getMessageType()); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + } else { + return super.getFieldBuilder(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + final Object value = extensions.getRepeatedFieldAllowBuilders(field, index); + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setRepeatedField(field, index, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } else { + return super.getRepeatedFieldBuilder(field, index); + } + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions != null && extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public BuilderT setField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setField(field, value); + onChanged(); + return (BuilderT) this; + } else { + return super.setField(field, value); + } + } + + @Override + public BuilderT clearField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.clearField(field); + onChanged(); + return (BuilderT) this; + } else { + return super.clearField(field); + } + } + + @Override + public BuilderT setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setRepeatedField(field, index, value); + onChanged(); + return (BuilderT) this; + } else { + return super.setRepeatedField(field, index, value); + } + } + + @Override + public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.addRepeatedField(field, value); + onChanged(); + return (BuilderT) this; + } else { + return super.addRepeatedField(field, value); + } + } + + @Override + public Message.Builder newBuilderForField(final FieldDescriptor field) { + if (field.isExtension()) { + return DynamicMessage.newBuilder(field.getMessageType()); + } else { + return super.newBuilderForField(field); + } + } + + protected final void mergeExtensionFields(final ExtendableMessage other) { + if (other.extensions != null) { + ensureExtensionsIsMutable(); + extensions.mergeFrom(other.extensions); + onChanged(); + } + } + + @Override + protected boolean parseUnknownField( + CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) + throws IOException { + ensureExtensionsIsMutable(); + return MessageReflection.mergeFieldFrom( + input, + input.shouldDiscardUnknownFields() ? null : getUnknownFieldSetBuilder(), + extensionRegistry, + getDescriptorForType(), + new MessageReflection.ExtensionBuilderAdapter(extensions), + tag); + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + // ----------------------------------------------------------------- + + /** + * Gets the descriptor for an extension. The implementation depends on whether the extension is + * scoped in the top level of a file or scoped in a Message. + */ + interface ExtensionDescriptorRetriever { + FieldDescriptor getDescriptor(); + } + + // ================================================================= + + /** Calls Class.getMethod and throws a RuntimeException if it fails. */ + private static Method getMethodOrDie( + final Class clazz, final String name, final Class... params) { + try { + return clazz.getMethod(name, params); + } catch (NoSuchMethodException e) { + throw new IllegalStateException( + "Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".", + e); + } + } + + /** Calls invoke and throws a RuntimeException if it fails. */ + @CanIgnoreReturnValue + private static Object invokeOrDie( + final Method method, final Object object, final Object... params) { + try { + return method.invoke(object, params); + } catch (IllegalAccessException e) { + throw new IllegalStateException( + "Couldn't use Java reflection to implement protocol message reflection.", e); + } catch (InvocationTargetException e) { + final Throwable cause = e.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } else if (cause instanceof Error) { + throw (Error) cause; + } else { + throw new IllegalStateException( + "Unexpected exception thrown by generated accessor method.", cause); + } + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but the + * generated API only allows us to access it as a map. This method returns the underlying map + * field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings("unused") + protected MapFieldReflectionAccessor internalGetMapFieldReflection(int fieldNumber) { + return internalGetMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"rawtypes", "unused"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + + /** + * Users should ignore this class. This class provides the implementation with access to the + * fields of a message object using Java reflection. + */ + public static final class FieldAccessorTable { + + /** + * Construct a FieldAccessorTable for a particular message class. Only one FieldAccessorTable + * should ever be constructed per class. + * + * @param descriptor The type's descriptor. + * @param camelCaseNames The camelcase names of all fields in the message. These are used to + * derive the accessor method names. + * @param messageClass The message type. + * @param builderClass The builder type. + */ + public FieldAccessorTable( + final Descriptor descriptor, + final String[] camelCaseNames, + final Class messageClass, + final Class> builderClass) { + this(descriptor, camelCaseNames); + ensureFieldAccessorsInitialized(messageClass, builderClass); + } + + /** + * Construct a FieldAccessorTable for a particular message class without initializing + * FieldAccessors. + */ + public FieldAccessorTable(final Descriptor descriptor, final String[] camelCaseNames) { + this.descriptor = descriptor; + this.camelCaseNames = camelCaseNames; + fields = new FieldAccessor[descriptor.getFields().size()]; + oneofs = new OneofAccessor[descriptor.getOneofs().size()]; + initialized = false; + } + + /** + * Ensures the field accessors are initialized. This method is thread-safe. + * + * @param messageClass The message type. + * @param builderClass The builder type. + * @return this + */ + public FieldAccessorTable ensureFieldAccessorsInitialized( + Class messageClass, Class> builderClass) { + if (initialized) { + return this; + } + synchronized (this) { + if (initialized) { + return this; + } + int fieldsSize = fields.length; + for (int i = 0; i < fieldsSize; i++) { + FieldDescriptor field = descriptor.getFields().get(i); + String containingOneofCamelCaseName = null; + if (field.getContainingOneof() != null) { + int index = fieldsSize + field.getContainingOneof().getIndex(); + if (index < camelCaseNames.length) { + containingOneofCamelCaseName = camelCaseNames[index]; + } + } + if (field.isRepeated()) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isMapField()) { + fields[i] = new MapFieldAccessor(field, messageClass); + } else { + fields[i] = + new RepeatedMessageFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new RepeatedEnumFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } else { + fields[i] = + new RepeatedFieldAccessor(field, camelCaseNames[i], messageClass, builderClass); + } + } else { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + fields[i] = + new SingularMessageFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new SingularEnumFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.STRING) { + fields[i] = + new SingularStringFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else { + fields[i] = + new SingularFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } + } + } + + for (int i = 0; i < descriptor.getOneofs().size(); i++) { + if (i < descriptor.getRealOneofs().size()) { + oneofs[i] = + new RealOneofAccessor( + descriptor, i, camelCaseNames[i + fieldsSize], messageClass, builderClass); + } else { + oneofs[i] = new SyntheticOneofAccessor(descriptor, i); + } + } + + initialized = true; + camelCaseNames = null; + return this; + } + } + + private final Descriptor descriptor; + private final FieldAccessor[] fields; + private String[] camelCaseNames; + private final OneofAccessor[] oneofs; + private volatile boolean initialized; + + /** Get the FieldAccessor for a particular field. */ + private FieldAccessor getField(final FieldDescriptor field) { + if (field.getContainingType() != descriptor) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } else if (field.isExtension()) { + // If this type had extensions, it would subclass ExtendableMessage, + // which overrides the reflection interface to handle extensions. + throw new IllegalArgumentException("This type does not have extensions."); + } + return fields[field.getIndex()]; + } + + /** Get the OneofAccessor for a particular oneof. */ + private OneofAccessor getOneof(final OneofDescriptor oneof) { + if (oneof.getContainingType() != descriptor) { + throw new IllegalArgumentException("OneofDescriptor does not match message type."); + } + return oneofs[oneof.getIndex()]; + } + + /** + * Abstract interface that provides access to a single field. This is implemented differently + * depending on the field type and cardinality. + */ + private interface FieldAccessor { + Object get(FlattenedGeneratedMessageV3 message); + + Object get(FlattenedGeneratedMessageV3.Builder builder); + + Object getRaw(FlattenedGeneratedMessageV3 message); + + void set(Builder builder, Object value); + + Object getRepeated(FlattenedGeneratedMessageV3 message, int index); + + Object getRepeated(FlattenedGeneratedMessageV3.Builder builder, int index); + + void setRepeated(Builder builder, int index, Object value); + + void addRepeated(Builder builder, Object value); + + boolean has(FlattenedGeneratedMessageV3 message); + + boolean has(FlattenedGeneratedMessageV3.Builder builder); + + int getRepeatedCount(FlattenedGeneratedMessageV3 message); + + int getRepeatedCount(FlattenedGeneratedMessageV3.Builder builder); + + void clear(Builder builder); + + Message.Builder newBuilder(); + + Message.Builder getBuilder(FlattenedGeneratedMessageV3.Builder builder); + + Message.Builder getRepeatedBuilder(FlattenedGeneratedMessageV3.Builder builder, int index); + } + + /** OneofAccessor provides access to a single oneof. */ + private static interface OneofAccessor { + public boolean has(final FlattenedGeneratedMessageV3 message); + + public boolean has(FlattenedGeneratedMessageV3.Builder builder); + + public FieldDescriptor get(final FlattenedGeneratedMessageV3 message); + + public FieldDescriptor get(FlattenedGeneratedMessageV3.Builder builder); + + public void clear(final Builder builder); + } + + /** RealOneofAccessor provides access to a single real oneof. */ + private static class RealOneofAccessor implements OneofAccessor { + RealOneofAccessor( + final Descriptor descriptor, + final int oneofIndex, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + this.descriptor = descriptor; + caseMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Case"); + caseMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Case"); + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + private final Descriptor descriptor; + private final Method caseMethod; + private final Method caseMethodBuilder; + private final Method clearMethod; + + @Override + public boolean has(final FlattenedGeneratedMessageV3 message) { + return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() != 0; + } + + @Override + public boolean has(FlattenedGeneratedMessageV3.Builder builder) { + return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() != 0; + } + + @Override + public FieldDescriptor get(final FlattenedGeneratedMessageV3 message) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + @Override + public FieldDescriptor get(FlattenedGeneratedMessageV3.Builder builder) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + @Override + public void clear(final Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + /** SyntheticOneofAccessor provides access to a single synthetic oneof. */ + private static class SyntheticOneofAccessor implements OneofAccessor { + SyntheticOneofAccessor(final Descriptor descriptor, final int oneofIndex) { + OneofDescriptor oneofDescriptor = descriptor.getOneofs().get(oneofIndex); + fieldDescriptor = oneofDescriptor.getFields().get(0); + } + + private final FieldDescriptor fieldDescriptor; + + @Override + public boolean has(final FlattenedGeneratedMessageV3 message) { + return message.hasField(fieldDescriptor); + } + + @Override + public boolean has(FlattenedGeneratedMessageV3.Builder builder) { + return builder.hasField(fieldDescriptor); + } + + @Override + public FieldDescriptor get(final FlattenedGeneratedMessageV3 message) { + return message.hasField(fieldDescriptor) ? fieldDescriptor : null; + } + + public FieldDescriptor get(FlattenedGeneratedMessageV3.Builder builder) { + return builder.hasField(fieldDescriptor) ? fieldDescriptor : null; + } + + @Override + public void clear(final Builder builder) { + builder.clearField(fieldDescriptor); + } + } + + // --------------------------------------------------------------- + + @SuppressWarnings("SameNameButDifferent") + private static class SingularFieldAccessor implements FieldAccessor { + private interface MethodInvoker { + Object get(final FlattenedGeneratedMessageV3 message); + + Object get(FlattenedGeneratedMessageV3.Builder builder); + + int getOneofFieldNumber(final FlattenedGeneratedMessageV3 message); + + int getOneofFieldNumber(final FlattenedGeneratedMessageV3.Builder builder); + + void set(final FlattenedGeneratedMessageV3.Builder builder, final Object value); + + boolean has(final FlattenedGeneratedMessageV3 message); + + boolean has(FlattenedGeneratedMessageV3.Builder builder); + + void clear(final FlattenedGeneratedMessageV3.Builder builder); + } + + private static final class ReflectionInvoker implements MethodInvoker { + private final Method getMethod; + private final Method getMethodBuilder; + private final Method setMethod; + private final Method hasMethod; + private final Method hasMethodBuilder; + private final Method clearMethod; + private final Method caseMethod; + private final Method caseMethodBuilder; + + ReflectionInvoker( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName, + boolean isOneofField, + boolean hasHasMethod) { + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName); + Class type = getMethod.getReturnType(); + setMethod = getMethodOrDie(builderClass, "set" + camelCaseName, type); + hasMethod = hasHasMethod ? getMethodOrDie(messageClass, "has" + camelCaseName) : null; + hasMethodBuilder = + hasHasMethod ? getMethodOrDie(builderClass, "has" + camelCaseName) : null; + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + caseMethod = + isOneofField + ? getMethodOrDie(messageClass, "get" + containingOneofCamelCaseName + "Case") + : null; + caseMethodBuilder = + isOneofField + ? getMethodOrDie(builderClass, "get" + containingOneofCamelCaseName + "Case") + : null; + } + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(FlattenedGeneratedMessageV3.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public int getOneofFieldNumber(final FlattenedGeneratedMessageV3 message) { + return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + } + + @Override + public int getOneofFieldNumber(final FlattenedGeneratedMessageV3.Builder builder) { + return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + } + + @Override + public void set(final FlattenedGeneratedMessageV3.Builder builder, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setMethod, builder, value); + } + + @Override + public boolean has(final FlattenedGeneratedMessageV3 message) { + return (Boolean) invokeOrDie(hasMethod, message); + } + + @Override + public boolean has(FlattenedGeneratedMessageV3.Builder builder) { + return (Boolean) invokeOrDie(hasMethodBuilder, builder); + } + + @Override + public void clear(final FlattenedGeneratedMessageV3.Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + SingularFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + isOneofField = + descriptor.getRealContainingOneof() != null; + hasHasMethod = + descriptor.getFile().getSyntax() == FileDescriptor.Syntax.EDITIONS && descriptor.hasPresence() + || descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO2 + || descriptor.hasOptionalKeyword() + || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); + ReflectionInvoker reflectionInvoker = + new ReflectionInvoker( + descriptor, + camelCaseName, + messageClass, + builderClass, + containingOneofCamelCaseName, + isOneofField, + hasHasMethod); + field = descriptor; + type = reflectionInvoker.getMethod.getReturnType(); + invoker = getMethodInvoker(reflectionInvoker); + } + + static MethodInvoker getMethodInvoker(ReflectionInvoker accessor) { + return accessor; + } + + // Note: We use Java reflection to call public methods rather than + // access private fields directly as this avoids runtime security + // checks. + protected final Class type; + protected final FieldDescriptor field; + protected final boolean isOneofField; + protected final boolean hasHasMethod; + protected final MethodInvoker invoker; + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + return invoker.get(message); + } + + @Override + public Object get(FlattenedGeneratedMessageV3.Builder builder) { + return invoker.get(builder); + } + + @Override + public Object getRaw(final FlattenedGeneratedMessageV3 message) { + return get(message); + } + + @Override + public void set(final Builder builder, final Object value) { + invoker.set(builder, value); + } + + @Override + public Object getRepeated(final FlattenedGeneratedMessageV3 message, final int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public Object getRepeated(FlattenedGeneratedMessageV3.Builder builder, int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + throw new UnsupportedOperationException("setRepeatedField() called on a singular field."); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + throw new UnsupportedOperationException("addRepeatedField() called on a singular field."); + } + + @Override + public boolean has(final FlattenedGeneratedMessageV3 message) { + if (!hasHasMethod) { + if (isOneofField) { + return invoker.getOneofFieldNumber(message) == field.getNumber(); + } + return !get(message).equals(field.getDefaultValue()); + } + return invoker.has(message); + } + + @Override + public boolean has(FlattenedGeneratedMessageV3.Builder builder) { + if (!hasHasMethod) { + if (isOneofField) { + return invoker.getOneofFieldNumber(builder) == field.getNumber(); + } + return !get(builder).equals(field.getDefaultValue()); + } + return invoker.has(builder); + } + + @Override + public int getRepeatedCount(final FlattenedGeneratedMessageV3 message) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public int getRepeatedCount(FlattenedGeneratedMessageV3.Builder builder) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public void clear(final Builder builder) { + invoker.clear(builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(FlattenedGeneratedMessageV3.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(FlattenedGeneratedMessageV3.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + @SuppressWarnings("SameNameButDifferent") + private static class RepeatedFieldAccessor implements FieldAccessor { + interface MethodInvoker { + Object get(final FlattenedGeneratedMessageV3 message); + + Object get(FlattenedGeneratedMessageV3.Builder builder); + + Object getRepeated(final FlattenedGeneratedMessageV3 message, final int index); + + Object getRepeated(FlattenedGeneratedMessageV3.Builder builder, int index); + + void setRepeated( + final FlattenedGeneratedMessageV3.Builder builder, final int index, final Object value); + + void addRepeated(final FlattenedGeneratedMessageV3.Builder builder, final Object value); + + int getRepeatedCount(final FlattenedGeneratedMessageV3 message); + + int getRepeatedCount(FlattenedGeneratedMessageV3.Builder builder); + + void clear(final FlattenedGeneratedMessageV3.Builder builder); + } + + private static final class ReflectionInvoker implements MethodInvoker { + private final Method getMethod; + private final Method getMethodBuilder; + private final Method getRepeatedMethod; + private final Method getRepeatedMethodBuilder; + private final Method setRepeatedMethod; + private final Method addRepeatedMethod; + private final Method getCountMethod; + private final Method getCountMethodBuilder; + private final Method clearMethod; + + ReflectionInvoker( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "List"); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "List"); + getRepeatedMethod = getMethodOrDie(messageClass, "get" + camelCaseName, Integer.TYPE); + getRepeatedMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName, Integer.TYPE); + Class type = getRepeatedMethod.getReturnType(); + setRepeatedMethod = + getMethodOrDie(builderClass, "set" + camelCaseName, Integer.TYPE, type); + addRepeatedMethod = getMethodOrDie(builderClass, "add" + camelCaseName, type); + getCountMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Count"); + getCountMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Count"); + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(FlattenedGeneratedMessageV3.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public Object getRepeated(final FlattenedGeneratedMessageV3 message, final int index) { + return invokeOrDie(getRepeatedMethod, message, index); + } + + @Override + public Object getRepeated(FlattenedGeneratedMessageV3.Builder builder, int index) { + return invokeOrDie(getRepeatedMethodBuilder, builder, index); + } + + @Override + public void setRepeated( + final FlattenedGeneratedMessageV3.Builder builder, final int index, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setRepeatedMethod, builder, index, value); + } + + @Override + public void addRepeated(final FlattenedGeneratedMessageV3.Builder builder, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(addRepeatedMethod, builder, value); + } + + @Override + public int getRepeatedCount(final FlattenedGeneratedMessageV3 message) { + return (Integer) invokeOrDie(getCountMethod, message); + } + + @Override + public int getRepeatedCount(FlattenedGeneratedMessageV3.Builder builder) { + return (Integer) invokeOrDie(getCountMethodBuilder, builder); + } + + @Override + public void clear(final FlattenedGeneratedMessageV3.Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + protected final Class type; + protected final MethodInvoker invoker; + + RepeatedFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + ReflectionInvoker reflectionInvoker = + new ReflectionInvoker(descriptor, camelCaseName, messageClass, builderClass); + type = reflectionInvoker.getRepeatedMethod.getReturnType(); + invoker = getMethodInvoker(reflectionInvoker); + } + + static MethodInvoker getMethodInvoker(ReflectionInvoker accessor) { + return accessor; + } + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + return invoker.get(message); + } + + @Override + public Object get(FlattenedGeneratedMessageV3.Builder builder) { + return invoker.get(builder); + } + + @Override + public Object getRaw(final FlattenedGeneratedMessageV3 message) { + return get(message); + } + + @Override + public void set(final Builder builder, final Object value) { + // Add all the elements individually. This serves two purposes: + // 1) Verifies that each element has the correct type. + // 2) Insures that the caller cannot modify the list later on and + // have the modifications be reflected in the message. + clear(builder); + for (final Object element : (List) value) { + addRepeated(builder, element); + } + } + + @Override + public Object getRepeated(final FlattenedGeneratedMessageV3 message, final int index) { + return invoker.getRepeated(message, index); + } + + @Override + public Object getRepeated(FlattenedGeneratedMessageV3.Builder builder, int index) { + return invoker.getRepeated(builder, index); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + invoker.setRepeated(builder, index, value); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + invoker.addRepeated(builder, value); + } + + @Override + public boolean has(final FlattenedGeneratedMessageV3 message) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public boolean has(FlattenedGeneratedMessageV3.Builder builder) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public int getRepeatedCount(final FlattenedGeneratedMessageV3 message) { + return invoker.getRepeatedCount(message); + } + + @Override + public int getRepeatedCount(FlattenedGeneratedMessageV3.Builder builder) { + return invoker.getRepeatedCount(builder); + } + + @Override + public void clear(final Builder builder) { + invoker.clear(builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(FlattenedGeneratedMessageV3.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(FlattenedGeneratedMessageV3.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + private static class MapFieldAccessor implements FieldAccessor { + MapFieldAccessor( + final FieldDescriptor descriptor, final Class messageClass) { + field = descriptor; + Method getDefaultInstanceMethod = getMethodOrDie(messageClass, "getDefaultInstance"); + MapFieldReflectionAccessor defaultMapField = + getMapField((FlattenedGeneratedMessageV3) invokeOrDie(getDefaultInstanceMethod, null)); + mapEntryMessageDefaultInstance = defaultMapField.getMapEntryMessageDefaultInstance(); + } + + private final FieldDescriptor field; + private final Message mapEntryMessageDefaultInstance; + + private MapFieldReflectionAccessor getMapField(FlattenedGeneratedMessageV3 message) { + return message.internalGetMapFieldReflection(field.getNumber()); + } + + private MapFieldReflectionAccessor getMapField(FlattenedGeneratedMessageV3.Builder builder) { + return builder.internalGetMapFieldReflection(field.getNumber()); + } + + private MapFieldReflectionAccessor getMutableMapField(FlattenedGeneratedMessageV3.Builder builder) { + return builder.internalGetMutableMapFieldReflection(field.getNumber()); + } + + private Message coerceType(Message value) { + if (value == null) { + return null; + } + if (mapEntryMessageDefaultInstance.getClass().isInstance(value)) { + return value; + } + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return mapEntryMessageDefaultInstance.toBuilder().mergeFrom(value).build(); + } + + @Override + public Object get(FlattenedGeneratedMessageV3 message) { + List result = new ArrayList<>(); + for (int i = 0; i < getRepeatedCount(message); i++) { + result.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + public Object get(Builder builder) { + List result = new ArrayList<>(); + for (int i = 0; i < getRepeatedCount(builder); i++) { + result.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + public Object getRaw(FlattenedGeneratedMessageV3 message) { + return get(message); + } + + @Override + public void set(Builder builder, Object value) { + clear(builder); + for (Object entry : (List) value) { + addRepeated(builder, entry); + } + } + + @Override + public Object getRepeated(FlattenedGeneratedMessageV3 message, int index) { + return getMapField(message).getList().get(index); + } + + @Override + public Object getRepeated(Builder builder, int index) { + return getMapField(builder).getList().get(index); + } + + @Override + public void setRepeated(Builder builder, int index, Object value) { + getMutableMapField(builder).getMutableList().set(index, coerceType((Message) value)); + } + + @Override + public void addRepeated(Builder builder, Object value) { + getMutableMapField(builder).getMutableList().add(coerceType((Message) value)); + } + + @Override + public boolean has(FlattenedGeneratedMessageV3 message) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public boolean has(Builder builder) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public int getRepeatedCount(FlattenedGeneratedMessageV3 message) { + return getMapField(message).getList().size(); + } + + @Override + public int getRepeatedCount(Builder builder) { + return getMapField(builder).getList().size(); + } + + @Override + public void clear(Builder builder) { + getMutableMapField(builder).getMutableList().clear(); + } + + @Override + public Message.Builder newBuilder() { + return mapEntryMessageDefaultInstance.newBuilderForType(); + } + + @Override + public Message.Builder getBuilder(Builder builder) { + throw new UnsupportedOperationException("Nested builder not supported for map fields."); + } + + @Override + public Message.Builder getRepeatedBuilder(Builder builder, int index) { + throw new UnsupportedOperationException("Map fields cannot be repeated"); + } + } + + // --------------------------------------------------------------- + + private static final class SingularEnumFieldAccessor extends SingularFieldAccessor { + SingularEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getValueMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Value"); + getValueMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Value"); + setValueMethod = getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class); + } + } + + private final EnumDescriptor enumDescriptor; + + private final Method valueOfMethod; + private final Method getValueDescriptorMethod; + + private final boolean supportUnknownEnumValue; + private Method getValueMethod; + private Method getValueMethodBuilder; + private Method setValueMethod; + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethod, message); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(message)); + } + + @Override + public Object get(final FlattenedGeneratedMessageV3.Builder builder) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethodBuilder, builder); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(builder)); + } + + @Override + public void set(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie(setValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.set(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + private static final class RepeatedEnumFieldAccessor extends RepeatedFieldAccessor { + RepeatedEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getRepeatedValueMethod = + getMethodOrDie(messageClass, "get" + camelCaseName + "Value", int.class); + getRepeatedValueMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Value", int.class); + setRepeatedValueMethod = + getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class, int.class); + addRepeatedValueMethod = + getMethodOrDie(builderClass, "add" + camelCaseName + "Value", int.class); + } + } + + private final EnumDescriptor enumDescriptor; + + private final Method valueOfMethod; + private final Method getValueDescriptorMethod; + + private final boolean supportUnknownEnumValue; + + private Method getRepeatedValueMethod; + private Method getRepeatedValueMethodBuilder; + private Method setRepeatedValueMethod; + private Method addRepeatedValueMethod; + + @Override + public Object get(final FlattenedGeneratedMessageV3 message) { + final List newList = new ArrayList<>(); + final int size = getRepeatedCount(message); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + public Object get(final FlattenedGeneratedMessageV3.Builder builder) { + final List newList = new ArrayList<>(); + final int size = getRepeatedCount(builder); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + public Object getRepeated(final FlattenedGeneratedMessageV3 message, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethod, message, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(message, index)); + } + + @Override + public Object getRepeated(final FlattenedGeneratedMessageV3.Builder builder, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethodBuilder, builder, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(builder, index)); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie( + setRepeatedValueMethod, + builder, + index, + ((EnumValueDescriptor) value).getNumber()); + return; + } + super.setRepeated(builder, index, invokeOrDie(valueOfMethod, null, value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie( + addRepeatedValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.addRepeated(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + // --------------------------------------------------------------- + + /** + * Field accessor for string fields. + * + *

This class makes getFooBytes() and setFooBytes() available for reflection API so that + * reflection based serialize/parse functions can access the raw bytes of the field to preserve + * non-UTF8 bytes in the string. + * + *

This ensures the serialize/parse round-trip safety, which is important for servers which + * forward messages. + */ + private static final class SingularStringFieldAccessor extends SingularFieldAccessor { + SingularStringFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + getBytesMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Bytes"); + setBytesMethodBuilder = + getMethodOrDie(builderClass, "set" + camelCaseName + "Bytes", ByteString.class); + } + + private final Method getBytesMethod; + private final Method setBytesMethodBuilder; + + @Override + public Object getRaw(final FlattenedGeneratedMessageV3 message) { + return invokeOrDie(getBytesMethod, message); + } + + @Override + public void set(FlattenedGeneratedMessageV3.Builder builder, Object value) { + if (value instanceof ByteString) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setBytesMethodBuilder, builder, value); + } else { + super.set(builder, value); + } + } + } + + // --------------------------------------------------------------- + + private static final class SingularMessageFieldAccessor extends SingularFieldAccessor { + SingularMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Builder"); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .buildPartial(); + } + } + + @Override + public void set(final Builder builder, final Object value) { + super.set(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getBuilder(FlattenedGeneratedMessageV3.Builder builder) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder); + } + } + + private static final class RepeatedMessageFieldAccessor extends RepeatedFieldAccessor { + RepeatedMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Builder", Integer.TYPE); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .build(); + } + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + super.setRepeated(builder, index, coerceType(value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + super.addRepeated(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getRepeatedBuilder( + final FlattenedGeneratedMessageV3.Builder builder, final int index) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder, index); + } + } + } + + /** + * Replaces this object in the output stream with a serialized form. Part of Java's serialization + * magic. Generated sub-classes must override this method by calling {@code return + * super.writeReplace();} + * + * @return a SerializedForm of this message + */ + protected Object writeReplace() throws ObjectStreamException { + return new SerializedForm(this); + } + + /** + * Checks that the {@link Extension} is non-Lite and returns it as a {@link GeneratedExtension}. + */ + private static , T> + Extension checkNotLite(ExtensionLite extension) { + if (extension.isLite()) { + throw new IllegalArgumentException("Expected non-lite extension."); + } + + return (Extension) extension; + } + + protected static boolean isStringEmpty(final Object value) { + if (value instanceof String) { + return ((String) value).isEmpty(); + } else { + return ((ByteString) value).isEmpty(); + } + } + + protected static int computeStringSize(final int fieldNumber, final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSize(fieldNumber, (String) value); + } else { + return CodedOutputStream.computeBytesSize(fieldNumber, (ByteString) value); + } + } + + protected static int computeStringSizeNoTag(final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSizeNoTag((String) value); + } else { + return CodedOutputStream.computeBytesSizeNoTag((ByteString) value); + } + } + + protected static void writeString( + CodedOutputStream output, final int fieldNumber, final Object value) throws IOException { + if (value instanceof String) { + output.writeString(fieldNumber, (String) value); + } else { + output.writeBytes(fieldNumber, (ByteString) value); + } + } + + protected static void writeStringNoTag(CodedOutputStream output, final Object value) + throws IOException { + if (value instanceof String) { + output.writeStringNoTag((String) value); + } else { + output.writeBytesNoTag((ByteString) value); + } + } + + protected static void serializeIntegerMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + // Sorting the unboxed keys and then look up the values during serialization is 2x faster + // than sorting map entries with a custom comparator directly. + int[] keys = new int[m.size()]; + int index = 0; + for (int k : m.keySet()) { + keys[index++] = k; + } + Arrays.sort(keys); + for (int key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeLongMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + + long[] keys = new long[m.size()]; + int index = 0; + for (long k : m.keySet()) { + keys[index++] = k; + } + Arrays.sort(keys); + for (long key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeStringMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + + // Sorting the String keys and then look up the values during serialization is 25% faster than + // sorting map entries with a custom comparator directly. + String[] keys = new String[m.size()]; + keys = m.keySet().toArray(keys); + Arrays.sort(keys); + for (String key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeBooleanMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + maybeSerializeBooleanEntryTo(out, m, defaultEntry, fieldNumber, false); + maybeSerializeBooleanEntryTo(out, m, defaultEntry, fieldNumber, true); + } + + private static void maybeSerializeBooleanEntryTo( + CodedOutputStream out, + Map m, + MapEntry defaultEntry, + int fieldNumber, + boolean key) + throws IOException { + if (m.containsKey(key)) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + /** Serialize the map using the iteration order. */ + private static void serializeMapTo( + CodedOutputStream out, Map m, MapEntry defaultEntry, int fieldNumber) + throws IOException { + for (Map.Entry entry : m.entrySet()) { + out.writeMessage( + fieldNumber, + defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build()); + } + } +} diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FloatValue.java b/protobuf-api/src/main/java/com/google/protobuf/FloatValue.java similarity index 94% rename from protobuf-sdk/src/main/java/com/google/protobuf/FloatValue.java rename to protobuf-api/src/main/java/com/google/protobuf/FloatValue.java index 4b4a8d4..b7d2b36 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/FloatValue.java +++ b/protobuf-api/src/main/java/com/google/protobuf/FloatValue.java @@ -14,12 +14,12 @@ * Protobuf type {@code google.protobuf.FloatValue} */ public final class FloatValue extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.FloatValue) FloatValueOrBuilder { private static final long serialVersionUID = 0L; // Use FloatValue.newBuilder() to construct. - private FloatValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private FloatValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private FloatValue() { @@ -38,7 +38,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_FloatValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -161,20 +161,20 @@ public static com.google.protobuf.FloatValue parseFrom( } public static com.google.protobuf.FloatValue parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.FloatValue parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.FloatValue parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -182,20 +182,20 @@ public static com.google.protobuf.FloatValue parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.FloatValue parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.FloatValue parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -215,7 +215,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -229,7 +229,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.FloatValue} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.FloatValue) com.google.protobuf.FloatValueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -238,7 +238,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_FloatValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -251,7 +251,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/FloatValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/FloatValueOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/FloatValueOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/FloatValueOrBuilder.java diff --git a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageInternal.java b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageInternal.java new file mode 100644 index 0000000..e247677 --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageInternal.java @@ -0,0 +1,2986 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf; + +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.EnumDescriptor; +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.FileDescriptor; +import com.google.protobuf.Descriptors.OneofDescriptor; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * All generated protocol message classes extend this class. This class implements most of the + * Message and Builder interfaces using Java reflection. Users can ignore this class and pretend + * that generated messages implement the Message interface directly. + * + * @author kenton@google.com Kenton Varda + */ +abstract class GeneratedMessageInternal extends AbstractMessageInternal implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * For testing. Allows a test to disable the optimization that avoids using field builders for + * nested messages until they are requested. By disabling this optimization, existing tests can be + * reused to test the field builders. + */ + protected static boolean alwaysUseFieldBuilders = false; + + /** For use by generated code only. */ + protected UnknownFieldSet unknownFields; + + protected GeneratedMessageInternal() { + unknownFields = UnknownFieldSet.getDefaultInstance(); + } + + protected GeneratedMessageInternal(Builder builder) { + unknownFields = builder.getUnknownFields(); + } + + @Override + public boolean isGenerated() { + return true; + } + + @Override + public Parser getParserForType() { + throw new UnsupportedOperationException("This is supposed to be overridden by subclasses."); + } + + /** + * For testing. Allows a test to disable the optimization that avoids using field builders for + * nested messages until they are requested. By disabling this optimization, existing tests can be + * reused to test the field builders. See {@link RepeatedFieldBuilder} and {@link + * SingleFieldBuilder}. + */ + static void enableAlwaysUseFieldBuildersForTesting() { + alwaysUseFieldBuilders = true; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + @Override + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + /** + * Internal helper to return a modifiable map containing all the fields. The returned Map is + * modifialbe so that the caller can add additional extension fields to implement {@link + * #getAllFields()}. + * + * @param getBytesForString whether to generate ByteString for string fields + */ + private Map getAllFieldsMutable(boolean getBytesForString) { + final TreeMap result = new TreeMap(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + if (getBytesForString && field.getJavaType() == FieldDescriptor.JavaType.STRING) { + result.put(field, getFieldRaw(field)); + } else { + result.put(field, getField(field)); + } + } + return result; + } + + @Override + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + + return true; + } + + @Override + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString = */ false)); + } + + /** + * Returns a collection of all the fields in this message which are set and their corresponding + * values. A singular ("required" or "optional") field is set iff hasField() returns true for that + * field. A "repeated" field is set iff getRepeatedFieldCount() is greater than zero. The values + * are exactly what would be returned by calling {@link #getFieldRaw(FieldDescriptor)} + * for each field. The map is guaranteed to be a sorted map, so iterating over it will return + * fields in order by field number. + */ + Map getAllFieldsRaw() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString = */ true)); + } + + @Override + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + @Override + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + @Override + public Object getField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).get(this); + } + + /** + * Obtains the value of the given field, or the default value if it is not set. For primitive + * fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the + * value is returned. For embedded message fields, the sub-message is returned. For repeated + * fields, a java.util.List is returned. For present string fields, a ByteString is returned + * representing the bytes that the field contains. + */ + Object getFieldRaw(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRaw(this); + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + @Override + public UnknownFieldSet getUnknownFields() { + throw new UnsupportedOperationException("This is supposed to be overridden by subclasses."); + } + + /** + * Called by subclasses to parse an unknown field. + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return unknownFields.mergeFieldFrom(tag, input); + } + + protected static M parseWithIOException(Parser parser, InputStream input) + throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static M parseWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static M parseWithIOException( + Parser parser, CodedInputStream input) throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static M parseWithIOException( + Parser parser, CodedInputStream input, ExtensionRegistryLite extensions) + throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input) throws IOException { + try { + return parser.parseDelimitedFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseDelimitedFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + @Override + public void writeTo(final CodedOutputStream output) throws IOException { + MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false); + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) { + return size; + } + + memoizedSize = MessageReflection.getSerializedSize(this, getAllFieldsRaw()); + return memoizedSize; + } + + /** Used by parsing constructors in generated classes. */ + protected void makeExtensionsImmutable() { + // Noop for messages without extensions. + } + + /** + * TODO: remove this after b/29368482 is fixed. We need to move this interface to + * AbstractMessage in order to versioning GeneratedMessageInternal but this move breaks binary + * compatibility for AppEngine. After AppEngine is fixed we can exclude this from google3. + */ + protected interface BuilderParent extends AbstractMessageInternal.BuilderParent {} + + /** TODO: remove this together with GeneratedMessageInternal.BuilderParent. */ + protected abstract Message.Builder newBuilderForType(BuilderParent parent); + + public Message.Builder newBuilderForType(final Message.BuilderParent parent) { + return newBuilderForType( + new BuilderParent() { + @Override + public void markDirty() { + parent.markDirty(); + } + }); + } + + @SuppressWarnings("unchecked") + public abstract static class Builder> + extends AbstractMessageInternal.Builder { + + private BuilderParent builderParent; + + private BuilderParentImpl meAsParent; + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See GeneratedMessageInternal.BuilderListener. + private boolean isClean; + + private UnknownFieldSet unknownFields = UnknownFieldSet.getDefaultInstance(); + + protected Builder() { + this(null); + } + + protected Builder(BuilderParent builderParent) { + this.builderParent = builderParent; + } + + @Override + public boolean isGenerated() { + return true; + } + + @Override + public void dispose() { + builderParent = null; + } + + /** Called by the subclass when a message is built. */ + protected void onBuilt() { + if (builderParent != null) { + markClean(); + } + } + + /** + * Called by the subclass or a builder to notify us that a message was built and may be cached + * and therefore invalidations are needed. + */ + @Override + public void markClean() { + this.isClean = true; + } + + /** + * Gets whether invalidations are needed + * + * @return whether invalidations are needed + */ + protected boolean isClean() { + return isClean; + } + + @Override + public BuilderType clone() { + BuilderType builder = (BuilderType) getDefaultInstanceForType().newBuilderForType(); + builder.mergeFrom(buildPartial()); + return builder; + } + + /** + * Called by the initialization and clear code paths to allow subclasses to reset any of their + * builtin fields back to the initial values. + */ + @Override + public BuilderType clear() { + unknownFields = UnknownFieldSet.getDefaultInstance(); + onChanged(); + return (BuilderType) this; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + @Override + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + @Override + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable()); + } + + /** Internal helper which returns a mutable map. */ + private Map getAllFieldsMutable() { + final TreeMap result = new TreeMap(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + result.put(field, getField(field)); + } + return result; + } + + @Override + public Message.Builder newBuilderForField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).newBuilder(); + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getBuilder(this); + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + return internalGetFieldAccessorTable().getField(field).getRepeatedBuilder(this, index); + } + + @Override + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + @Override + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + @Override + public Object getField(final FieldDescriptor field) { + Object object = internalGetFieldAccessorTable().getField(field).get(this); + if (field.isRepeated()) { + // The underlying list object is still modifiable at this point. + // Make sure not to expose the modifiable list to the caller. + return Collections.unmodifiableList((List) object); + } else { + return object; + } + } + + @Override + public BuilderType setField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).set(this, value); + return (BuilderType) this; + } + + @Override + public BuilderType clearField(final FieldDescriptor field) { + internalGetFieldAccessorTable().getField(field).clear(this); + return (BuilderType) this; + } + + @Override + public BuilderType clearOneof(final OneofDescriptor oneof) { + internalGetFieldAccessorTable().getOneof(oneof).clear(this); + return (BuilderType) this; + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + @Override + public BuilderType setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + internalGetFieldAccessorTable().getField(field).setRepeated(this, index, value); + return (BuilderType) this; + } + + @Override + public BuilderType addRepeatedField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).addRepeated(this, value); + return (BuilderType) this; + } + + @Override + public BuilderType setUnknownFields(final UnknownFieldSet unknownFields) { + this.unknownFields = unknownFields; + onChanged(); + return (BuilderType) this; + } + + @Override + public BuilderType mergeUnknownFields(final UnknownFieldSet unknownFields) { + this.unknownFields = + UnknownFieldSet.newBuilder(this.unknownFields).mergeFrom(unknownFields).build(); + onChanged(); + return (BuilderType) this; + } + + @Override + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + return true; + } + + @Override + public final UnknownFieldSet getUnknownFields() { + return unknownFields; + } + + /** + * Called by subclasses to parse an unknown field. + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + final CodedInputStream input, + final UnknownFieldSet.Builder unknownFields, + final ExtensionRegistryLite extensionRegistry, + final int tag) + throws IOException { + return unknownFields.mergeFieldFrom(tag, input); + } + + /** + * Implementation of {@link BuilderParent} for giving to our children. This small inner class + * makes it so we don't publicly expose the BuilderParent methods. + */ + private class BuilderParentImpl implements BuilderParent { + + @Override + public void markDirty() { + onChanged(); + } + } + + /** + * Gets the {@link BuilderParent} for giving to our children. + * + * @return The builder parent for our children. + */ + protected BuilderParent getParentForChildren() { + if (meAsParent == null) { + meAsParent = new BuilderParentImpl(); + } + return meAsParent; + } + + /** + * Called when a the builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + protected final void onChanged() { + if (isClean && builderParent != null) { + builderParent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but + * the generated API only allows us to access it as a map. This method returns the underlying + * map field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new RuntimeException("No map fields found in " + getClass().getName()); + } + + /** Like {@link #internalGetMapField} but return a mutable version. */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMutableMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new RuntimeException("No map fields found in " + getClass().getName()); + } + } + + // ================================================================= + // Extensions-related stuff + + public interface ExtendableMessageOrBuilder + extends MessageOrBuilder { + // Re-define for return type covariance. + @Override + Message getDefaultInstanceForType(); + + /** Check if a singular extension is present. */ + boolean hasExtension(ExtensionLite extension); + + /** Get the number of elements in a repeated extension. */ + int getExtensionCount(ExtensionLite> extension); + + /** Get the value of an extension. */ + Type getExtension(ExtensionLite extension); + + /** Get one element of a repeated extension. */ + Type getExtension(ExtensionLite> extension, int index); + + /** Check if a singular extension is present. */ + boolean hasExtension(Extension extension); + /** Check if a singular extension is present. */ + boolean hasExtension(GeneratedExtension extension); + /** Get the number of elements in a repeated extension. */ + int getExtensionCount(Extension> extension); + /** Get the number of elements in a repeated extension. */ + int getExtensionCount(GeneratedExtension> extension); + /** Get the value of an extension. */ + Type getExtension(Extension extension); + /** Get the value of an extension. */ + Type getExtension(GeneratedExtension extension); + /** Get one element of a repeated extension. */ + Type getExtension(Extension> extension, int index); + /** Get one element of a repeated extension. */ + Type getExtension(GeneratedExtension> extension, int index); + } + + /** + * Generated message classes for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "has", "get", and "getCount" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo = getFoo();
+   * int i = foo.getExtension(MyProto.bar);
+   * 
+ * + *

See also {@link ExtendableBuilder}. + */ + public abstract static class ExtendableMessage + extends GeneratedMessageInternal implements ExtendableMessageOrBuilder { + + private static final long serialVersionUID = 1L; + + private final FieldSet extensions; + + protected ExtendableMessage() { + this.extensions = FieldSet.newFieldSet(); + } + + protected ExtendableMessage(ExtendableBuilder builder) { + super(builder); + this.extensions = builder.buildExtensions(); + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + @SuppressWarnings("unchecked") + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + @SuppressWarnings("unchecked") + public final int getExtensionCount( + final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + @SuppressWarnings("unchecked") + public final Type getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (Type) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (Type) extension.getMessageDefaultInstance(); + } else { + return (Type) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (Type) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + @SuppressWarnings("unchecked") + public final Type getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + return (Type) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension( + final GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount( + final GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension(final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get one element of a repeated extension. */ + @Override + public final Type getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** Get one element of a repeated extension. */ + @Override + public final Type getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions.isInitialized(); + } + + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + @Override + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return MessageReflection.mergeFieldFrom( + input, + unknownFields, + extensionRegistry, + getDescriptorForType(), + new MessageReflection.ExtensionAdapter(extensions), + tag); + } + + /** Used by parsing constructors in generated classes. */ + @Override + protected void makeExtensionsImmutable() { + extensions.makeImmutable(); + } + + /** + * Used by subclasses to serialize extensions. Extension ranges may be interleaved with field + * numbers, but we must write them in canonical (sorted by field number) order. ExtensionWriter + * helps us write individual ranges of extensions at once. + */ + protected class ExtensionWriter { + // Imagine how much simpler this code would be if Java iterators had + // a way to get the next element without advancing the iterator. + + private final Iterator> iter = extensions.iterator(); + private Map.Entry next; + private final boolean messageSetWireFormat; + + private ExtensionWriter(final boolean messageSetWireFormat) { + if (iter.hasNext()) { + next = iter.next(); + } + this.messageSetWireFormat = messageSetWireFormat; + } + + public void writeUntil(final int end, final CodedOutputStream output) throws IOException { + while (next != null && next.getKey().getNumber() < end) { + FieldDescriptor descriptor = next.getKey(); + if (messageSetWireFormat + && descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE + && !descriptor.isRepeated()) { + if (next instanceof LazyField.LazyEntry) { + output.writeRawMessageSetExtension( + descriptor.getNumber(), + ((LazyField.LazyEntry) next).getField().toByteString()); + } else { + output.writeMessageSetExtension(descriptor.getNumber(), (Message) next.getValue()); + } + } else { + // TODO: Taken care of following code, it may cause + // problem when we use LazyField for normal fields/extensions. + // Due to the optional field can be duplicated at the end of + // serialized bytes, which will make the serialized size change + // after lazy field parsed. So when we use LazyField globally, + // we need to change the following write method to write cached + // bytes directly rather than write the parsed message. + FieldSet.writeField(descriptor, next.getValue(), output); + } + if (iter.hasNext()) { + next = iter.next(); + } else { + next = null; + } + } + } + } + + protected ExtensionWriter newExtensionWriter() { + return new ExtensionWriter(false); + } + + protected ExtensionWriter newMessageSetExtensionWriter() { + return new ExtensionWriter(true); + } + + /** Called by subclasses to compute the size of extensions. */ + protected int extensionsSerializedSize() { + return extensions.getSerializedSize(); + } + + protected int extensionsSerializedSizeAsMessageSet() { + return extensions.getMessageSetSerializedSize(); + } + + // --------------------------------------------------------------- + // Reflection + + protected Map getExtensionFields() { + return extensions.getAllFields(); + } + + @Override + public Map getAllFields() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString = */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public Map getAllFieldsRaw() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString = */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions.getField(field); + if (value == null) { + if (field.isRepeated()) { + return Collections.emptyList(); + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + /** + * Generated message builders for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "get", "set", and "add" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo =
+   *   MyProto.Foo.newBuilder()
+   *     .setExtension(MyProto.bar, 123)
+   *     .build();
+   * 
+ * + *

See also {@link ExtendableMessage}. + */ + @SuppressWarnings("unchecked") + public abstract static class ExtendableBuilder< + MessageType extends ExtendableMessage, + BuilderType extends ExtendableBuilder> + extends Builder implements ExtendableMessageOrBuilder { + + private FieldSet extensions = FieldSet.emptySet(); + + protected ExtendableBuilder() {} + + protected ExtendableBuilder(BuilderParent parent) { + super(parent); + } + + // For immutable message conversion. + void internalSetExtensionSet(FieldSet extensions) { + this.extensions = extensions; + } + + @Override + public BuilderType clear() { + extensions = FieldSet.emptySet(); + return super.clear(); + } + + // This is implemented here only to work around an apparent bug in the + // Java compiler and/or build system. See bug #1898463. The mere presence + // of this clone() implementation makes it go away. + @Override + public BuilderType clone() { + return super.clone(); + } + + private void ensureExtensionsIsMutable() { + if (extensions.isImmutable()) { + extensions = extensions.clone(); + } + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount( + final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + public final Type getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (Type) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (Type) extension.getMessageDefaultInstance(); + } else { + return (Type) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (Type) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + public final Type getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + return (Type) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** Set the value of an extension. */ + public final BuilderType setExtension( + final ExtensionLite extensionLite, final Type value) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setField(descriptor, extension.toReflectionType(value)); + onChanged(); + return (BuilderType) this; + } + + /** Set the value of one element of a repeated extension. */ + public final BuilderType setExtension( + final ExtensionLite> extensionLite, + final int index, + final Type value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setRepeatedField(descriptor, index, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderType) this; + } + + /** Append a value to a repeated extension. */ + public final BuilderType addExtension( + final ExtensionLite> extensionLite, final Type value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.addRepeatedField(descriptor, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderType) this; + } + + /** Clear an extension. */ + public final BuilderType clearExtension( + final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + extensions.clearField(extension.getDescriptor()); + onChanged(); + return (BuilderType) this; + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension( + final GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount( + final GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension(final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** Get the value of an extension. */ + @Override + public final Type getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** Set the value of an extension. */ + public final BuilderType setExtension( + final Extension extension, final Type value) { + return setExtension((ExtensionLite) extension, value); + } + /** Set the value of an extension. */ + public BuilderType setExtension( + final GeneratedExtension extension, final Type value) { + return setExtension((ExtensionLite) extension, value); + } + /** Set the value of one element of a repeated extension. */ + public final BuilderType setExtension( + final Extension> extension, final int index, final Type value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** Set the value of one element of a repeated extension. */ + public BuilderType setExtension( + final GeneratedExtension> extension, + final int index, + final Type value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** Append a value to a repeated extension. */ + public final BuilderType addExtension( + final Extension> extension, final Type value) { + return addExtension((ExtensionLite>) extension, value); + } + /** Append a value to a repeated extension. */ + public BuilderType addExtension( + final GeneratedExtension> extension, final Type value) { + return addExtension((ExtensionLite>) extension, value); + } + /** Clear an extension. */ + public final BuilderType clearExtension(final Extension extension) { + return clearExtension((ExtensionLite) extension); + } + /** Clear an extension. */ + public BuilderType clearExtension(final GeneratedExtension extension) { + return clearExtension((ExtensionLite) extension); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions.isInitialized(); + } + + /** + * Called by the build code path to create a copy of the extensions for building the message. + */ + private FieldSet buildExtensions() { + extensions.makeImmutable(); + return extensions; + } + + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + /** + * Called by subclasses to parse an unknown field or an extension. + * + * @return {@code true} unless the tag is an end-group tag. + */ + @Override + protected boolean parseUnknownField( + final CodedInputStream input, + final UnknownFieldSet.Builder unknownFields, + final ExtensionRegistryLite extensionRegistry, + final int tag) + throws IOException { + return MessageReflection.mergeFieldFrom( + input, + unknownFields, + extensionRegistry, + getDescriptorForType(), + new MessageReflection.BuilderAdapter(this), + tag); + } + + // --------------------------------------------------------------- + // Reflection + + @Override + public Map getAllFields() { + final Map result = super.getAllFieldsMutable(); + result.putAll(extensions.getAllFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions.getField(field); + if (value == null) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public BuilderType setField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setField(field, value); + onChanged(); + return (BuilderType) this; + } else { + return super.setField(field, value); + } + } + + @Override + public BuilderType clearField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.clearField(field); + onChanged(); + return (BuilderType) this; + } else { + return super.clearField(field); + } + } + + @Override + public BuilderType setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setRepeatedField(field, index, value); + onChanged(); + return (BuilderType) this; + } else { + return super.setRepeatedField(field, index, value); + } + } + + @Override + public BuilderType addRepeatedField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.addRepeatedField(field, value); + onChanged(); + return (BuilderType) this; + } else { + return super.addRepeatedField(field, value); + } + } + + protected final void mergeExtensionFields(final ExtendableMessage other) { + ensureExtensionsIsMutable(); + extensions.mergeFrom(other.extensions); + onChanged(); + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + // ----------------------------------------------------------------- + + /** + * Gets the descriptor for an extension. The implementation depends on whether the extension is + * scoped in the top level of a file or scoped in a Message. + */ + static interface ExtensionDescriptorRetriever { + FieldDescriptor getDescriptor(); + } + + /** For use by generated code only. */ + public static + GeneratedExtension newMessageScopedGeneratedExtension( + final Message scope, + final int descriptorIndex, + final Class singularType, + final Message defaultInstance) { + // For extensions scoped within a Message, we use the Message to resolve + // the outer class's descriptor, from which the extension descriptor is + // obtained. + return new GeneratedExtension( + new CachedDescriptorRetriever() { + @Override + public FieldDescriptor loadDescriptor() { + return scope.getDescriptorForType().getExtensions().get(descriptorIndex); + } + }, + singularType, + defaultInstance, + Extension.ExtensionType.IMMUTABLE); + } + + /** For use by generated code only. */ + public static + GeneratedExtension newFileScopedGeneratedExtension( + final Class singularType, final Message defaultInstance) { + // For extensions scoped within a file, we rely on the outer class's + // static initializer to call internalInit() on the extension when the + // descriptor is available. + return new GeneratedExtension( + null, // ExtensionDescriptorRetriever is initialized in internalInit(); + singularType, + defaultInstance, + Extension.ExtensionType.IMMUTABLE); + } + + private abstract static class CachedDescriptorRetriever implements ExtensionDescriptorRetriever { + private volatile FieldDescriptor descriptor; + + protected abstract FieldDescriptor loadDescriptor(); + + @Override + public FieldDescriptor getDescriptor() { + if (descriptor == null) { + synchronized (this) { + if (descriptor == null) { + descriptor = loadDescriptor(); + } + } + } + return descriptor; + } + } + + /** + * Used in proto1 generated code only. + * + *

After enabling bridge, we can define proto2 extensions (the extended type is a proto2 + * mutable message) in a proto1 .proto file. For these extensions we should generate proto2 + * GeneratedExtensions. + */ + public static + GeneratedExtension newMessageScopedGeneratedExtension( + final Message scope, + final String name, + final Class singularType, + final Message defaultInstance) { + // For extensions scoped within a Message, we use the Message to resolve + // the outer class's descriptor, from which the extension descriptor is + // obtained. + return new GeneratedExtension( + new CachedDescriptorRetriever() { + @Override + protected FieldDescriptor loadDescriptor() { + return scope.getDescriptorForType().findFieldByName(name); + } + }, + singularType, + defaultInstance, + Extension.ExtensionType.MUTABLE); + } + + /** + * Used in proto1 generated code only. + * + *

After enabling bridge, we can define proto2 extensions (the extended type is a proto2 + * mutable message) in a proto1 .proto file. For these extensions we should generate proto2 + * GeneratedExtensions. + */ + public static + GeneratedExtension newFileScopedGeneratedExtension( + final Class singularType, + final Message defaultInstance, + final String descriptorOuterClass, + final String extensionName) { + // For extensions scoped within a file, we load the descriptor outer + // class and rely on it to get the FileDescriptor which then can be + // used to obtain the extension's FieldDescriptor. + return new GeneratedExtension( + new CachedDescriptorRetriever() { + @Override + protected FieldDescriptor loadDescriptor() { + try { + Class clazz = singularType.getClassLoader().loadClass(descriptorOuterClass); + FileDescriptor file = (FileDescriptor) clazz.getField("descriptor").get(null); + return file.findExtensionByName(extensionName); + } catch (Exception e) { + throw new RuntimeException( + "Cannot load descriptors: " + + descriptorOuterClass + + " is not a valid descriptor class name", + e); + } + } + }, + singularType, + defaultInstance, + Extension.ExtensionType.MUTABLE); + } + + /** + * Type used to represent generated extensions. The protocol compiler generates a static singleton + * instance of this class for each extension. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then, {@code MyProto.Foo.bar} has type {@code GeneratedExtension}. + * + *

In general, users should ignore the details of this type, and simply use these static + * singletons as parameters to the extension accessors defined in {@link ExtendableMessage} and + * {@link ExtendableBuilder}. + */ + public static class GeneratedExtension + extends Extension { + // TODO: Find ways to avoid using Java reflection within this + // class. Also try to avoid suppressing unchecked warnings. + + // We can't always initialize the descriptor of a GeneratedExtension when + // we first construct it due to initialization order difficulties (namely, + // the descriptor may not have been constructed yet, since it is often + // constructed by the initializer of a separate module). + // + // In the case of nested extensions, we initialize the + // ExtensionDescriptorRetriever with an instance that uses the scoping + // Message's default instance to retrieve the extension's descriptor. + // + // In the case of non-nested extensions, we initialize the + // ExtensionDescriptorRetriever to null and rely on the outer class's static + // initializer to call internalInit() after the descriptor has been parsed. + GeneratedExtension( + ExtensionDescriptorRetriever descriptorRetriever, + Class singularType, + Message messageDefaultInstance, + ExtensionType extensionType) { + if (Message.class.isAssignableFrom(singularType) + && !singularType.isInstance(messageDefaultInstance)) { + throw new IllegalArgumentException( + "Bad messageDefaultInstance for " + singularType.getName()); + } + this.descriptorRetriever = descriptorRetriever; + this.singularType = singularType; + this.messageDefaultInstance = messageDefaultInstance; + + if (ProtocolMessageEnum.class.isAssignableFrom(singularType)) { + this.enumValueOf = getMethodOrDie(singularType, "valueOf", EnumValueDescriptor.class); + this.enumGetValueDescriptor = getMethodOrDie(singularType, "getValueDescriptor"); + } else { + this.enumValueOf = null; + this.enumGetValueDescriptor = null; + } + this.extensionType = extensionType; + } + + /** For use by generated code only. */ + public void internalInit(final FieldDescriptor descriptor) { + if (descriptorRetriever != null) { + throw new IllegalStateException("Already initialized."); + } + descriptorRetriever = + new ExtensionDescriptorRetriever() { + @Override + public FieldDescriptor getDescriptor() { + return descriptor; + } + }; + } + + private ExtensionDescriptorRetriever descriptorRetriever; + private final Class singularType; + private final Message messageDefaultInstance; + private final Method enumValueOf; + private final Method enumGetValueDescriptor; + private final ExtensionType extensionType; + + @Override + public FieldDescriptor getDescriptor() { + if (descriptorRetriever == null) { + throw new IllegalStateException("getDescriptor() called before internalInit()"); + } + return descriptorRetriever.getDescriptor(); + } + + /** + * If the extension is an embedded message or group, returns the default instance of the + * message. + */ + @Override + public Message getMessageDefaultInstance() { + return messageDefaultInstance; + } + + @Override + protected ExtensionType getExtensionType() { + return extensionType; + } + + /** + * Convert from the type used by the reflection accessors to the type used by native accessors. + * E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors + * use the generated enum type. + */ + @Override + @SuppressWarnings("unchecked") + protected Object fromReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + if (descriptor.isRepeated()) { + if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE + || descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) { + // Must convert the whole list. + final List result = new ArrayList(); + for (final Object element : (List) value) { + result.add(singularFromReflectionType(element)); + } + return result; + } else { + return value; + } + } else { + return singularFromReflectionType(value); + } + } + + /** + * Like {@link #fromReflectionType(Object)}, but if the type is a repeated type, this converts a + * single element. + */ + @Override + protected Object singularFromReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + switch (descriptor.getJavaType()) { + case MESSAGE: + if (singularType.isInstance(value)) { + return value; + } else { + return messageDefaultInstance.newBuilderForType().mergeFrom((Message) value).build(); + } + case ENUM: + return invokeOrDie(enumValueOf, null, (EnumValueDescriptor) value); + default: + return value; + } + } + + /** + * Convert from the type used by the native accessors to the type used by reflection accessors. + * E.g., for enums, the reflection accessors use EnumValueDescriptors but the native accessors + * use the generated enum type. + */ + @Override + @SuppressWarnings("unchecked") + protected Object toReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + if (descriptor.isRepeated()) { + if (descriptor.getJavaType() == FieldDescriptor.JavaType.ENUM) { + // Must convert the whole list. + final List result = new ArrayList(); + for (final Object element : (List) value) { + result.add(singularToReflectionType(element)); + } + return result; + } else { + return value; + } + } else { + return singularToReflectionType(value); + } + } + + /** + * Like {@link #toReflectionType(Object)}, but if the type is a repeated type, this converts a + * single element. + */ + @Override + protected Object singularToReflectionType(final Object value) { + FieldDescriptor descriptor = getDescriptor(); + switch (descriptor.getJavaType()) { + case ENUM: + return invokeOrDie(enumGetValueDescriptor, value); + default: + return value; + } + } + + @Override + public int getNumber() { + return getDescriptor().getNumber(); + } + + @Override + public WireFormat.FieldType getLiteType() { + return getDescriptor().getLiteType(); + } + + @Override + public boolean isRepeated() { + return getDescriptor().isRepeated(); + } + + @Override + @SuppressWarnings("unchecked") + public Type getDefaultValue() { + if (isRepeated()) { + return (Type) Collections.emptyList(); + } + if (getDescriptor().getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (Type) messageDefaultInstance; + } + return (Type) singularFromReflectionType(getDescriptor().getDefaultValue()); + } + } + + // ================================================================= + + /** Calls Class.getMethod and throws a RuntimeException if it fails. */ + @SuppressWarnings("unchecked") + private static Method getMethodOrDie( + final Class clazz, final String name, final Class... params) { + try { + return clazz.getMethod(name, params); + } catch (NoSuchMethodException e) { + throw new RuntimeException( + "Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".", + e); + } + } + + /** Calls invoke and throws a RuntimeException if it fails. */ + private static Object invokeOrDie( + final Method method, final Object object, final Object... params) { + try { + return method.invoke(object, params); + } catch (IllegalAccessException e) { + throw new RuntimeException( + "Couldn't use Java reflection to implement protocol message " + "reflection.", e); + } catch (InvocationTargetException e) { + final Throwable cause = e.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } else if (cause instanceof Error) { + throw (Error) cause; + } else { + throw new RuntimeException( + "Unexpected exception thrown by generated accessor method.", cause); + } + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but the + * generated API only allows us to access it as a map. This method returns the underlying map + * field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings({"rawtypes", "unused"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new RuntimeException("No map fields found in " + getClass().getName()); + } + + /** + * Users should ignore this class. This class provides the implementation with access to the + * fields of a message object using Java reflection. + */ + public static final class FieldAccessorTable { + + /** + * Construct a FieldAccessorTable for a particular message class. Only one FieldAccessorTable + * should ever be constructed per class. + * + * @param descriptor The type's descriptor. + * @param camelCaseNames The camelcase names of all fields in the message. These are used to + * derive the accessor method names. + * @param messageClass The message type. + * @param builderClass The builder type. + */ + public FieldAccessorTable( + final Descriptor descriptor, + final String[] camelCaseNames, + final Class messageClass, + final Class builderClass) { + this(descriptor, camelCaseNames); + ensureFieldAccessorsInitialized(messageClass, builderClass); + } + + /** + * Construct a FieldAccessorTable for a particular message class without initializing + * FieldAccessors. + */ + public FieldAccessorTable(final Descriptor descriptor, final String[] camelCaseNames) { + this.descriptor = descriptor; + this.camelCaseNames = camelCaseNames; + fields = new FieldAccessor[descriptor.getFields().size()]; + oneofs = new OneofAccessor[descriptor.getOneofs().size()]; + initialized = false; + } + + private boolean isMapFieldEnabled(FieldDescriptor field) { + boolean result = true; + return result; + } + + /** + * Ensures the field accessors are initialized. This method is thread-safe. + * + * @param messageClass The message type. + * @param builderClass The builder type. + * @return this + */ + public FieldAccessorTable ensureFieldAccessorsInitialized( + Class messageClass, Class builderClass) { + if (initialized) { + return this; + } + synchronized (this) { + if (initialized) { + return this; + } + int fieldsSize = fields.length; + for (int i = 0; i < fieldsSize; i++) { + FieldDescriptor field = descriptor.getFields().get(i); + String containingOneofCamelCaseName = null; + if (field.getContainingOneof() != null) { + containingOneofCamelCaseName = + camelCaseNames[fieldsSize + field.getContainingOneof().getIndex()]; + } + if (field.isRepeated()) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isMapField() && isMapFieldEnabled(field)) { + fields[i] = + new MapFieldAccessor(field, camelCaseNames[i], messageClass, builderClass); + } else { + fields[i] = + new RepeatedMessageFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new RepeatedEnumFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } else { + fields[i] = + new RepeatedFieldAccessor(field, camelCaseNames[i], messageClass, builderClass); + } + } else { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + fields[i] = + new SingularMessageFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new SingularEnumFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.STRING) { + fields[i] = + new SingularStringFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else { + fields[i] = + new SingularFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } + } + } + + int oneofsSize = oneofs.length; + for (int i = 0; i < oneofsSize; i++) { + oneofs[i] = + new OneofAccessor( + descriptor, camelCaseNames[i + fieldsSize], messageClass, builderClass); + } + initialized = true; + camelCaseNames = null; + return this; + } + } + + private final Descriptor descriptor; + private final FieldAccessor[] fields; + private String[] camelCaseNames; + private final OneofAccessor[] oneofs; + private volatile boolean initialized; + + /** Get the FieldAccessor for a particular field. */ + private FieldAccessor getField(final FieldDescriptor field) { + if (field.getContainingType() != descriptor) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } else if (field.isExtension()) { + // If this type had extensions, it would subclass ExtendableMessage, + // which overrides the reflection interface to handle extensions. + throw new IllegalArgumentException("This type does not have extensions."); + } + return fields[field.getIndex()]; + } + + /** Get the OneofAccessor for a particular oneof. */ + private OneofAccessor getOneof(final OneofDescriptor oneof) { + if (oneof.getContainingType() != descriptor) { + throw new IllegalArgumentException("OneofDescriptor does not match message type."); + } + return oneofs[oneof.getIndex()]; + } + + /** + * Abstract interface that provides access to a single field. This is implemented differently + * depending on the field type and cardinality. + */ + private interface FieldAccessor { + Object get(GeneratedMessageInternal message); + + Object get(GeneratedMessageInternal.Builder builder); + + Object getRaw(GeneratedMessageInternal message); + + Object getRaw(GeneratedMessageInternal.Builder builder); + + void set(Builder builder, Object value); + + Object getRepeated(GeneratedMessageInternal message, int index); + + Object getRepeated(GeneratedMessageInternal.Builder builder, int index); + + Object getRepeatedRaw(GeneratedMessageInternal message, int index); + + Object getRepeatedRaw(GeneratedMessageInternal.Builder builder, int index); + + void setRepeated(Builder builder, int index, Object value); + + void addRepeated(Builder builder, Object value); + + boolean has(GeneratedMessageInternal message); + + boolean has(GeneratedMessageInternal.Builder builder); + + int getRepeatedCount(GeneratedMessageInternal message); + + int getRepeatedCount(GeneratedMessageInternal.Builder builder); + + void clear(Builder builder); + + Message.Builder newBuilder(); + + Message.Builder getBuilder(GeneratedMessageInternal.Builder builder); + + Message.Builder getRepeatedBuilder(GeneratedMessageInternal.Builder builder, int index); + } + + /** OneofAccessor provides access to a single oneof. */ + private static class OneofAccessor { + OneofAccessor( + final Descriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass) { + this.descriptor = descriptor; + caseMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Case"); + caseMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Case"); + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + private final Descriptor descriptor; + private final Method caseMethod; + private final Method caseMethodBuilder; + private final Method clearMethod; + + public boolean has(final GeneratedMessageInternal message) { + if (((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() == 0) { + return false; + } + return true; + } + + public boolean has(GeneratedMessageInternal.Builder builder) { + if (((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() == 0) { + return false; + } + return true; + } + + public FieldDescriptor get(final GeneratedMessageInternal message) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + public FieldDescriptor get(GeneratedMessageInternal.Builder builder) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + public void clear(final Builder builder) { + invokeOrDie(clearMethod, builder); + } + } + + private static boolean supportFieldPresence(FileDescriptor file) { + return file.getSyntax() == FileDescriptor.Syntax.PROTO2; + } + + // --------------------------------------------------------------- + + private static class SingularFieldAccessor implements FieldAccessor { + SingularFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass, + final String containingOneofCamelCaseName) { + field = descriptor; + isOneofField = descriptor.getContainingOneof() != null; + hasHasMethod = + supportFieldPresence(descriptor.getFile()) + || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName); + type = getMethod.getReturnType(); + setMethod = getMethodOrDie(builderClass, "set" + camelCaseName, type); + hasMethod = hasHasMethod ? getMethodOrDie(messageClass, "has" + camelCaseName) : null; + hasMethodBuilder = + hasHasMethod ? getMethodOrDie(builderClass, "has" + camelCaseName) : null; + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + caseMethod = + isOneofField + ? getMethodOrDie(messageClass, "get" + containingOneofCamelCaseName + "Case") + : null; + caseMethodBuilder = + isOneofField + ? getMethodOrDie(builderClass, "get" + containingOneofCamelCaseName + "Case") + : null; + } + + // Note: We use Java reflection to call public methods rather than + // access private fields directly as this avoids runtime security + // checks. + protected final Class type; + protected final Method getMethod; + protected final Method getMethodBuilder; + protected final Method setMethod; + protected final Method hasMethod; + protected final Method hasMethodBuilder; + protected final Method clearMethod; + protected final Method caseMethod; + protected final Method caseMethodBuilder; + protected final FieldDescriptor field; + protected final boolean isOneofField; + protected final boolean hasHasMethod; + + private int getOneofFieldNumber(final GeneratedMessageInternal message) { + return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + } + + private int getOneofFieldNumber(final GeneratedMessageInternal.Builder builder) { + return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + } + + @Override + public Object get(final GeneratedMessageInternal message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(GeneratedMessageInternal.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public Object getRaw(final GeneratedMessageInternal message) { + return get(message); + } + + @Override + public Object getRaw(GeneratedMessageInternal.Builder builder) { + return get(builder); + } + + @Override + public void set(final Builder builder, final Object value) { + invokeOrDie(setMethod, builder, value); + } + + @Override + public Object getRepeated(final GeneratedMessageInternal message, final int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public Object getRepeatedRaw(final GeneratedMessageInternal message, final int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldRaw() called on a singular field."); + } + + @Override + public Object getRepeated(GeneratedMessageInternal.Builder builder, int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public Object getRepeatedRaw(GeneratedMessageInternal.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldRaw() called on a singular field."); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + throw new UnsupportedOperationException("setRepeatedField() called on a singular field."); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + throw new UnsupportedOperationException("addRepeatedField() called on a singular field."); + } + + @Override + public boolean has(final GeneratedMessageInternal message) { + if (!hasHasMethod) { + if (isOneofField) { + return getOneofFieldNumber(message) == field.getNumber(); + } + return !get(message).equals(field.getDefaultValue()); + } + return (Boolean) invokeOrDie(hasMethod, message); + } + + @Override + public boolean has(GeneratedMessageInternal.Builder builder) { + if (!hasHasMethod) { + if (isOneofField) { + return getOneofFieldNumber(builder) == field.getNumber(); + } + return !get(builder).equals(field.getDefaultValue()); + } + return (Boolean) invokeOrDie(hasMethodBuilder, builder); + } + + @Override + public int getRepeatedCount(final GeneratedMessageInternal message) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public int getRepeatedCount(GeneratedMessageInternal.Builder builder) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public void clear(final Builder builder) { + invokeOrDie(clearMethod, builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageInternal.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(GeneratedMessageInternal.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + private static class RepeatedFieldAccessor implements FieldAccessor { + protected final Class type; + protected final Method getMethod; + protected final Method getMethodBuilder; + protected final Method getRepeatedMethod; + protected final Method getRepeatedMethodBuilder; + protected final Method setRepeatedMethod; + protected final Method addRepeatedMethod; + protected final Method getCountMethod; + protected final Method getCountMethodBuilder; + protected final Method clearMethod; + + RepeatedFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass) { + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "List"); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "List"); + getRepeatedMethod = getMethodOrDie(messageClass, "get" + camelCaseName, Integer.TYPE); + getRepeatedMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName, Integer.TYPE); + type = getRepeatedMethod.getReturnType(); + setRepeatedMethod = getMethodOrDie(builderClass, "set" + camelCaseName, Integer.TYPE, type); + addRepeatedMethod = getMethodOrDie(builderClass, "add" + camelCaseName, type); + getCountMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Count"); + getCountMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Count"); + + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + @Override + public Object get(final GeneratedMessageInternal message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(GeneratedMessageInternal.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public Object getRaw(final GeneratedMessageInternal message) { + return get(message); + } + + @Override + public Object getRaw(GeneratedMessageInternal.Builder builder) { + return get(builder); + } + + @Override + public void set(final Builder builder, final Object value) { + // Add all the elements individually. This serves two purposes: + // 1) Verifies that each element has the correct type. + // 2) Insures that the caller cannot modify the list later on and + // have the modifications be reflected in the message. + clear(builder); + for (final Object element : (List) value) { + addRepeated(builder, element); + } + } + + @Override + public Object getRepeated(final GeneratedMessageInternal message, final int index) { + return invokeOrDie(getRepeatedMethod, message, index); + } + + @Override + public Object getRepeated(GeneratedMessageInternal.Builder builder, int index) { + return invokeOrDie(getRepeatedMethodBuilder, builder, index); + } + + @Override + public Object getRepeatedRaw(GeneratedMessageInternal message, int index) { + return getRepeated(message, index); + } + + @Override + public Object getRepeatedRaw(GeneratedMessageInternal.Builder builder, int index) { + return getRepeated(builder, index); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + invokeOrDie(setRepeatedMethod, builder, index, value); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + invokeOrDie(addRepeatedMethod, builder, value); + } + + @Override + public boolean has(final GeneratedMessageInternal message) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public boolean has(GeneratedMessageInternal.Builder builder) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public int getRepeatedCount(final GeneratedMessageInternal message) { + return (Integer) invokeOrDie(getCountMethod, message); + } + + @Override + public int getRepeatedCount(GeneratedMessageInternal.Builder builder) { + return (Integer) invokeOrDie(getCountMethodBuilder, builder); + } + + @Override + public void clear(final Builder builder) { + invokeOrDie(clearMethod, builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageInternal.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(GeneratedMessageInternal.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + private static class MapFieldAccessor implements FieldAccessor { + MapFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass) { + field = descriptor; + Method getDefaultInstanceMethod = getMethodOrDie(messageClass, "getDefaultInstance"); + MapField defaultMapField = + getMapField((GeneratedMessageInternal) invokeOrDie(getDefaultInstanceMethod, null)); + mapEntryMessageDefaultInstance = defaultMapField.getMapEntryMessageDefaultInstance(); + } + + private final FieldDescriptor field; + private final Message mapEntryMessageDefaultInstance; + + private MapField getMapField(GeneratedMessageInternal message) { + return (MapField) message.internalGetMapField(field.getNumber()); + } + + private MapField getMapField(GeneratedMessageInternal.Builder builder) { + return (MapField) builder.internalGetMapField(field.getNumber()); + } + + private MapField getMutableMapField(GeneratedMessageInternal.Builder builder) { + return (MapField) builder.internalGetMutableMapField(field.getNumber()); + } + + @Override + @SuppressWarnings("unchecked") + public Object get(GeneratedMessageInternal message) { + List result = new ArrayList(); + for (int i = 0; i < getRepeatedCount(message); i++) { + result.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + @SuppressWarnings("unchecked") + public Object get(Builder builder) { + List result = new ArrayList(); + for (int i = 0; i < getRepeatedCount(builder); i++) { + result.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + public Object getRaw(GeneratedMessageInternal message) { + return get(message); + } + + @Override + public Object getRaw(GeneratedMessageInternal.Builder builder) { + return get(builder); + } + + @Override + public void set(Builder builder, Object value) { + clear(builder); + for (Object entry : (List) value) { + addRepeated(builder, entry); + } + } + + @Override + public Object getRepeated(GeneratedMessageInternal message, int index) { + return getMapField(message).getList().get(index); + } + + @Override + public Object getRepeated(Builder builder, int index) { + return getMapField(builder).getList().get(index); + } + + @Override + public Object getRepeatedRaw(GeneratedMessageInternal message, int index) { + return getRepeated(message, index); + } + + @Override + public Object getRepeatedRaw(Builder builder, int index) { + return getRepeated(builder, index); + } + + @Override + public void setRepeated(Builder builder, int index, Object value) { + getMutableMapField(builder).getMutableList().set(index, (Message) value); + } + + @Override + public void addRepeated(Builder builder, Object value) { + getMutableMapField(builder).getMutableList().add((Message) value); + } + + @Override + public boolean has(GeneratedMessageInternal message) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public boolean has(Builder builder) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public int getRepeatedCount(GeneratedMessageInternal message) { + return getMapField(message).getList().size(); + } + + @Override + public int getRepeatedCount(Builder builder) { + return getMapField(builder).getList().size(); + } + + @Override + public void clear(Builder builder) { + getMutableMapField(builder).getMutableList().clear(); + } + + @Override + public Message.Builder newBuilder() { + return mapEntryMessageDefaultInstance.newBuilderForType(); + } + + @Override + public Message.Builder getBuilder(Builder builder) { + throw new UnsupportedOperationException("Nested builder not supported for map fields."); + } + + @Override + public Message.Builder getRepeatedBuilder(Builder builder, int index) { + throw new UnsupportedOperationException("Nested builder not supported for map fields."); + } + } + + // --------------------------------------------------------------- + + private static final class SingularEnumFieldAccessor extends SingularFieldAccessor { + SingularEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getValueMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Value"); + getValueMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Value"); + setValueMethod = getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class); + } + } + + private EnumDescriptor enumDescriptor; + + private Method valueOfMethod; + private Method getValueDescriptorMethod; + + private boolean supportUnknownEnumValue; + private Method getValueMethod; + private Method getValueMethodBuilder; + private Method setValueMethod; + + @Override + public Object get(final GeneratedMessageInternal message) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethod, message); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(message)); + } + + @Override + public Object get(final GeneratedMessageInternal.Builder builder) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethodBuilder, builder); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(builder)); + } + + @Override + public void set(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + invokeOrDie(setValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.set(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + private static final class RepeatedEnumFieldAccessor extends RepeatedFieldAccessor { + RepeatedEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getRepeatedValueMethod = + getMethodOrDie(messageClass, "get" + camelCaseName + "Value", int.class); + getRepeatedValueMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Value", int.class); + setRepeatedValueMethod = + getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class, int.class); + addRepeatedValueMethod = + getMethodOrDie(builderClass, "add" + camelCaseName + "Value", int.class); + } + } + + private EnumDescriptor enumDescriptor; + + private final Method valueOfMethod; + private final Method getValueDescriptorMethod; + + private boolean supportUnknownEnumValue; + private Method getRepeatedValueMethod; + private Method getRepeatedValueMethodBuilder; + private Method setRepeatedValueMethod; + private Method addRepeatedValueMethod; + + @Override + @SuppressWarnings("unchecked") + public Object get(final GeneratedMessageInternal message) { + final List newList = new ArrayList(); + final int size = getRepeatedCount(message); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + @SuppressWarnings("unchecked") + public Object get(final GeneratedMessageInternal.Builder builder) { + final List newList = new ArrayList(); + final int size = getRepeatedCount(builder); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + public Object getRepeated(final GeneratedMessageInternal message, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethod, message, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(message, index)); + } + + @Override + public Object getRepeated(final GeneratedMessageInternal.Builder builder, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethodBuilder, builder, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(builder, index)); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + if (supportUnknownEnumValue) { + invokeOrDie( + setRepeatedValueMethod, builder, index, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.setRepeated(builder, index, invokeOrDie(valueOfMethod, null, value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + invokeOrDie(addRepeatedValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.addRepeated(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + // --------------------------------------------------------------- + + /** + * Field accessor for string fields. + * + *

This class makes getFooBytes() and setFooBytes() available for reflection API so that + * reflection based serialize/parse functions can access the raw bytes of the field to preserve + * non-UTF8 bytes in the string. + * + *

This ensures the serialize/parse round-trip safety, which is important for servers which + * forward messages. + */ + private static final class SingularStringFieldAccessor extends SingularFieldAccessor { + SingularStringFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + getBytesMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Bytes"); + getBytesMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Bytes"); + setBytesMethodBuilder = + getMethodOrDie(builderClass, "set" + camelCaseName + "Bytes", ByteString.class); + } + + private final Method getBytesMethod; + private final Method getBytesMethodBuilder; + private final Method setBytesMethodBuilder; + + @Override + public Object getRaw(final GeneratedMessageInternal message) { + return invokeOrDie(getBytesMethod, message); + } + + @Override + public Object getRaw(GeneratedMessageInternal.Builder builder) { + return invokeOrDie(getBytesMethodBuilder, builder); + } + + @Override + public void set(GeneratedMessageInternal.Builder builder, Object value) { + if (value instanceof ByteString) { + invokeOrDie(setBytesMethodBuilder, builder, value); + } else { + super.set(builder, value); + } + } + } + + // --------------------------------------------------------------- + + private static final class SingularMessageFieldAccessor extends SingularFieldAccessor { + SingularMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Builder"); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .buildPartial(); + } + } + + @Override + public void set(final Builder builder, final Object value) { + super.set(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageInternal.Builder builder) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder); + } + } + + private static final class RepeatedMessageFieldAccessor extends RepeatedFieldAccessor { + RepeatedMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Builder", Integer.TYPE); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .build(); + } + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + super.setRepeated(builder, index, coerceType(value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + super.addRepeated(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getRepeatedBuilder( + final GeneratedMessageInternal.Builder builder, final int index) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder, index); + } + } + } + + /** + * Replaces this object in the output stream with a serialized form. Part of Java's serialization + * magic. Generated sub-classes must override this method by calling {@code return + * super.writeReplace();} + * + * @return a SerializedForm of this message + */ + protected Object writeReplace() throws ObjectStreamException { + return new SerializedForm(this); + } + + /** + * Checks that the {@link Extension} is non-Lite and returns it as a {@link GeneratedExtension}. + */ + private static , T> + Extension checkNotLite(ExtensionLite extension) { + if (extension.isLite()) { + throw new IllegalArgumentException("Expected non-lite extension."); + } + + return (Extension) extension; + } + + protected static int computeStringSize(final int fieldNumber, final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSize(fieldNumber, (String) value); + } else { + return CodedOutputStream.computeBytesSize(fieldNumber, (ByteString) value); + } + } + + protected static int computeStringSizeNoTag(final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSizeNoTag((String) value); + } else { + return CodedOutputStream.computeBytesSizeNoTag((ByteString) value); + } + } + + protected static void writeString( + CodedOutputStream output, final int fieldNumber, final Object value) throws IOException { + if (value instanceof String) { + output.writeString(fieldNumber, (String) value); + } else { + output.writeBytes(fieldNumber, (ByteString) value); + } + } + + protected static void writeStringNoTag(CodedOutputStream output, final Object value) + throws IOException { + if (value instanceof String) { + output.writeStringNoTag((String) value); + } else { + output.writeBytesNoTag((ByteString) value); + } + } +} diff --git a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageLite.java b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageLite.java index c153960..528636c 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageLite.java +++ b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageLite.java @@ -7,7 +7,6 @@ package com.google.protobuf; -import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream; import com.google.protobuf.Internal.BooleanList; import com.google.protobuf.Internal.DoubleList; import com.google.protobuf.Internal.FloatList; @@ -34,7 +33,7 @@ * * @author kenton@google.com Kenton Varda */ -public abstract class GeneratedMessageLite< +abstract class GeneratedMessageLite< MessageType extends GeneratedMessageLite, BuilderType extends GeneratedMessageLite.Builder> extends AbstractMessageLite { @@ -623,7 +622,7 @@ protected boolean parseUnknownField( // TODO: How much bytecode would be saved by not requiring the generated code to // provide the default instance? GeneratedExtension extension = - extensionRegistry.findLiteExtensionByNumber(defaultInstance, fieldNumber); + (GeneratedExtension) extensionRegistry.findLiteExtensionByNumber(defaultInstance, fieldNumber); return parseExtension(input, extensionRegistry, extension, tag, fieldNumber); } @@ -808,7 +807,7 @@ private void mergeMessageSetExtensionFromCoded if (tag == WireFormat.MESSAGE_SET_TYPE_ID_TAG) { typeId = input.readUInt32(); if (typeId != 0) { - extension = extensionRegistry.findLiteExtensionByNumber(defaultInstance, typeId); + extension = (GeneratedExtension) extensionRegistry.findLiteExtensionByNumber(defaultInstance, typeId); } } else if (tag == WireFormat.MESSAGE_SET_MESSAGE_TAG) { @@ -1395,93 +1394,6 @@ public Type getDefaultValue() { } } - /** - * A serialized (serializable) form of the generated message. Stores the message as a class name - * and a byte array. - */ - protected static final class SerializedForm implements Serializable { - - public static SerializedForm of(MessageLite message) { - return new SerializedForm(message); - } - - private static final long serialVersionUID = 0L; - - // since v3.6.1 - private final Class messageClass; - private final String messageClassName; - private final byte[] asBytes; - - /** - * Creates the serialized form by calling {@link com.google.protobuf.MessageLite#toByteArray}. - * - * @param regularForm the message to serialize - */ - SerializedForm(MessageLite regularForm) { - messageClass = regularForm.getClass(); - messageClassName = regularForm.getClass().getName(); - asBytes = regularForm.toByteArray(); - } - - /** - * When read from an ObjectInputStream, this method converts this object back to the regular - * form. Part of Java's serialization magic. - * - * @return a GeneratedMessage of the type that was serialized - */ - protected Object readResolve() throws ObjectStreamException { - try { - Class messageClass = resolveMessageClass(); - java.lang.reflect.Field defaultInstanceField = - messageClass.getDeclaredField("DEFAULT_INSTANCE"); - defaultInstanceField.setAccessible(true); - MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null); - return defaultInstance.newBuilderForType().mergeFrom(asBytes).buildPartial(); - } catch (ClassNotFoundException e) { - throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e); - } catch (NoSuchFieldException e) { - return readResolveFallback(); - } catch (SecurityException e) { - throw new RuntimeException("Unable to call DEFAULT_INSTANCE in " + messageClassName, e); - } catch (IllegalAccessException e) { - throw new RuntimeException("Unable to call parsePartialFrom", e); - } catch (InvalidProtocolBufferException e) { - throw new RuntimeException("Unable to understand proto buffer", e); - } - } - - /** - * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code. - */ - @Deprecated - private Object readResolveFallback() throws ObjectStreamException { - try { - Class messageClass = resolveMessageClass(); - java.lang.reflect.Field defaultInstanceField = - messageClass.getDeclaredField("defaultInstance"); - defaultInstanceField.setAccessible(true); - MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null); - return defaultInstance.newBuilderForType() - .mergeFrom(asBytes) - .buildPartial(); - } catch (ClassNotFoundException e) { - throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e); - } catch (NoSuchFieldException e) { - throw new RuntimeException("Unable to find defaultInstance in " + messageClassName, e); - } catch (SecurityException e) { - throw new RuntimeException("Unable to call defaultInstance in " + messageClassName, e); - } catch (IllegalAccessException e) { - throw new RuntimeException("Unable to call parsePartialFrom", e); - } catch (InvalidProtocolBufferException e) { - throw new RuntimeException("Unable to understand proto buffer", e); - } - } - - private Class resolveMessageClass() throws ClassNotFoundException { - return messageClass != null ? messageClass : Class.forName(messageClassName); - } - } - /** Checks that the {@link Extension} is Lite and returns it as a {@link GeneratedExtension}. */ private static < MessageType extends ExtendableMessage, diff --git a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3Internal.java b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3Internal.java new file mode 100644 index 0000000..5553325 --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3Internal.java @@ -0,0 +1,3413 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf; + +import com.google.protobuf.Descriptors.Descriptor; +import com.google.protobuf.Descriptors.EnumDescriptor; +import com.google.protobuf.Descriptors.EnumValueDescriptor; +import com.google.protobuf.Descriptors.FieldDescriptor; +import com.google.protobuf.Descriptors.FileDescriptor; +import com.google.protobuf.Descriptors.OneofDescriptor; +import com.google.protobuf.GeneratedMessageInternal.GeneratedExtension; +import com.google.protobuf.Internal.BooleanList; +import com.google.protobuf.Internal.DoubleList; +import com.google.protobuf.Internal.FloatList; +import com.google.protobuf.Internal.IntList; +import com.google.protobuf.Internal.LongList; +import com.google.protobuf.Internal.ProtobufList; + +import java.io.IOException; +import java.io.InputStream; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.TreeMap; + +/** + * All generated protocol message classes extend this class. This class implements most of the + * Message and Builder interfaces using Java reflection. Users can ignore this class and pretend + * that generated messages implement the Message interface directly. + * + * @author kenton@google.com Kenton Varda + */ +abstract class GeneratedMessageV3Internal extends AbstractMessageInternal implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * For testing. Allows a test to disable the optimization that avoids using field builders for + * nested messages until they are requested. By disabling this optimization, existing tests can be + * reused to test the field builders. + */ + protected static boolean alwaysUseFieldBuilders = false; + + /** + * For use by generated code only. + * + *

TODO: mark this private and final (breaking change) + */ + protected UnknownFieldSet unknownFields; + + protected GeneratedMessageV3Internal() { + unknownFields = UnknownFieldSet.getDefaultInstance(); + } + + protected GeneratedMessageV3Internal(Builder builder) { + unknownFields = builder.getUnknownFields(); + } + + /** TODO: Remove this unnecessary intermediate implementation of this method. */ + @Override + public Parser getParserForType() { + throw new UnsupportedOperationException("This is supposed to be overridden by subclasses."); + } + + /** + * TODO: Stop using SingleFieldBuilder and remove this setting + * + * @see #setAlwaysUseFieldBuildersForTesting(boolean) + */ + static void enableAlwaysUseFieldBuildersForTesting() { + setAlwaysUseFieldBuildersForTesting(true); + } + + /** + * For testing. Allows a test to disable/re-enable the optimization that avoids using field + * builders for nested messages until they are requested. By disabling this optimization, existing + * tests can be reused to test the field builders. See {@link RepeatedFieldBuilder} and {@link + * SingleFieldBuilder}. + * + *

TODO: Stop using SingleFieldBuilder and remove this setting + */ + static void setAlwaysUseFieldBuildersForTesting(boolean useBuilders) { + alwaysUseFieldBuilders = useBuilders; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + @Override + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + /** + * TODO: This method should be removed. It enables parsing directly into an + * "immutable" message. Have to leave it for now to support old gencode. + * + * @deprecated use newBuilder().mergeFrom() instead + */ + @Deprecated + protected void mergeFromAndMakeImmutableInternal( + CodedInputStream input, ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + Schema schema = Protobuf.getInstance().schemaFor(this); + try { + schema.mergeFrom(this, CodedInputStreamReader.forCodedInput(input), extensionRegistry); + } catch (InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(this); + } catch (IOException e) { + throw new InvalidProtocolBufferException(e).setUnfinishedMessage(this); + } + schema.makeImmutable(this); + } + + /** + * Internal helper to return a modifiable map containing all the fields. The returned Map is + * modifiable so that the caller can add additional extension fields to implement {@link + * #getAllFields()}. + * + * @param getBytesForString whether to generate ByteString for string fields + */ + private Map getAllFieldsMutable(boolean getBytesForString) { + final TreeMap result = new TreeMap<>(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + if (getBytesForString && field.getJavaType() == FieldDescriptor.JavaType.STRING) { + result.put(field, getFieldRaw(field)); + } else { + result.put(field, getField(field)); + } + } + return result; + } + + // TODO: compute this at {@code build()} time in the Builder class. + @Override + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + + return true; + } + + @Override + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString= */ false)); + } + + /** + * Returns a collection of all the fields in this message which are set and their corresponding + * values. A singular ("required" or "optional") field is set iff hasField() returns true for that + * field. A "repeated" field is set iff getRepeatedFieldCount() is greater than zero. The values + * are exactly what would be returned by calling {@link #getFieldRaw(FieldDescriptor)} + * for each field. The map is guaranteed to be a sorted map, so iterating over it will return + * fields in order by field number. + */ + Map getAllFieldsRaw() { + return Collections.unmodifiableMap(getAllFieldsMutable(/* getBytesForString= */ true)); + } + + @Override + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + @Override + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + @Override + public Object getField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).get(this); + } + + /** + * Obtains the value of the given field, or the default value if it is not set. For primitive + * fields, the boxed primitive value is returned. For enum fields, the EnumValueDescriptor for the + * value is returned. For embedded message fields, the sub-message is returned. For repeated + * fields, a java.util.List is returned. For present string fields, a ByteString is returned + * representing the bytes that the field contains. + */ + Object getFieldRaw(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRaw(this); + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + // TODO: This method should be final. + @Override + public UnknownFieldSet getUnknownFields() { + return unknownFields; + } + + // TODO: This should go away when Schema classes cannot modify immutable + // GeneratedMessageV3Internal objects anymore. + void setUnknownFields(UnknownFieldSet unknownFields) { + this.unknownFields = unknownFields; + } + + /** + * Called by subclasses to parse an unknown field. + * + *

TODO remove this method + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + if (input.shouldDiscardUnknownFields()) { + return input.skipField(tag); + } + return unknownFields.mergeFieldFrom(tag, input); + } + + /** + * Delegates to parseUnknownField. This method is obsolete, but we must retain it for + * compatibility with older generated code. + * + *

TODO remove this method + */ + protected boolean parseUnknownFieldProto3( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return parseUnknownField(input, unknownFields, extensionRegistry, tag); + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseWithIOException(Parser parser, InputStream input) + throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseWithIOException( + Parser parser, CodedInputStream input) throws IOException { + try { + return parser.parseFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseWithIOException( + Parser parser, CodedInputStream input, ExtensionRegistryLite extensions) + throws IOException { + try { + return parser.parseFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + @SuppressWarnings("ProtoParseWithRegistry") + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input) throws IOException { + try { + return parser.parseDelimitedFrom(input); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + /** Used by generated code. */ + protected static M parseDelimitedWithIOException( + Parser parser, InputStream input, ExtensionRegistryLite extensions) throws IOException { + try { + return parser.parseDelimitedFrom(input, extensions); + } catch (InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } + } + + protected static boolean canUseUnsafe() { + return UnsafeUtil.hasUnsafeArrayOperations() && UnsafeUtil.hasUnsafeByteBufferOperations(); + } + + protected static IntList emptyIntList() { + return IntArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static IntList newIntList() { + return new IntArrayList(); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static IntList mutableCopy(IntList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static LongList mutableCopy(LongList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static FloatList mutableCopy(FloatList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static DoubleList mutableCopy(DoubleList list) { + return makeMutableCopy(list); + } + + // TODO: Redundant with makeMutableCopy(). Remove. + protected static BooleanList mutableCopy(BooleanList list) { + return makeMutableCopy(list); + } + + protected static LongList emptyLongList() { + return LongArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static LongList newLongList() { + return new LongArrayList(); + } + + protected static FloatList emptyFloatList() { + return FloatArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static FloatList newFloatList() { + return new FloatArrayList(); + } + + protected static DoubleList emptyDoubleList() { + return DoubleArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static DoubleList newDoubleList() { + return new DoubleArrayList(); + } + + protected static BooleanList emptyBooleanList() { + return BooleanArrayList.emptyList(); + } + + // TODO: Unused. Remove. + protected static BooleanList newBooleanList() { + return new BooleanArrayList(); + } + + protected static > ListT makeMutableCopy(ListT list) { + return makeMutableCopy(list, 0); + } + + @SuppressWarnings("unchecked") // Guaranteed by proto runtime. + protected static > ListT makeMutableCopy( + ListT list, int minCapacity) { + int size = list.size(); + if (minCapacity <= size) { + minCapacity = size * 2; + } + if (minCapacity <= 0) { + minCapacity = AbstractProtobufList.DEFAULT_CAPACITY; + } + + return (ListT) list.mutableCopyWithCapacity(minCapacity); + } + + @SuppressWarnings("unchecked") // The empty list can be safely cast + protected static ProtobufList emptyList(Class elementType) { + return (ProtobufList) ProtobufArrayList.emptyList(); + } + + @Override + public void writeTo(final CodedOutputStream output) throws IOException { + MessageReflection.writeMessageTo(this, getAllFieldsRaw(), output, false); + } + + @Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) { + return size; + } + + memoizedSize = MessageReflection.getSerializedSize( + this, getAllFieldsRaw()); + return memoizedSize; + } + + /** + * This class is used to make a generated protected method inaccessible from user's code (e.g., + * the {@link #newInstance} method below). When this class is used as a parameter's type in a + * generated protected method, the method is visible to user's code in the same package, but since + * the constructor of this class is private to protobuf runtime, user's code can't obtain an + * instance of this class and as such can't actually make a method call on the protected method. + */ + protected static final class UnusedPrivateParameter { + static final UnusedPrivateParameter INSTANCE = new UnusedPrivateParameter(); + + private UnusedPrivateParameter() {} + } + + /** Creates a new instance of this message type. Overridden in the generated code. */ + @SuppressWarnings({"unused"}) + protected Object newInstance(UnusedPrivateParameter unused) { + throw new UnsupportedOperationException("This method must be overridden by the subclass."); + } + + /** + * Used by parsing constructors in generated classes. + * + *

TODO: remove unused method (extensions should be immutable after build) + */ + protected void makeExtensionsImmutable() { + // Noop for messages without extensions. + } + + /** + * TODO: remove this after b/29368482 is fixed. We need to move this interface to + * AbstractMessage in order to versioning GeneratedMessageV3Internal but this move breaks binary + * compatibility for AppEngine. After AppEngine is fixed we can exclude this from google3. + * + *

TODO: Remove at breaking change since b/29368482 was fixed in 2020 + */ + protected interface BuilderParent extends AbstractMessageInternal.BuilderParent {} + + /** TODO: remove this together with GeneratedMessageV3Internal.BuilderParent. */ + protected abstract Message.Builder newBuilderForType(BuilderParent parent); + + /** TODO: generated class should implement this directly */ + public Message.Builder newBuilderForType(final Message.BuilderParent parent) { + return newBuilderForType( + new BuilderParent() { + @Override + public void markDirty() { + parent.markDirty(); + } + }); + } + + /** Builder class for {@link GeneratedMessageV3Internal}. */ + @SuppressWarnings("unchecked") + public abstract static class Builder> + extends AbstractMessageInternal.Builder { + + private BuilderParent builderParent; + + private BuilderParentImpl meAsParent; + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See GeneratedMessageV3Internal.BuilderListener. + private boolean isClean; + + /** + * This field holds either an {@link UnknownFieldSet} or {@link UnknownFieldSet.Builder}. + * + *

We use an object because it should only be one or the other of those things at a time and + * Object is the only common base. This also saves space. + * + *

Conversions are lazy: if {@link #setUnknownFields} is called, this will contain {@link + * UnknownFieldSet}. If unknown fields are merged into this builder, the current {@link + * UnknownFieldSet} will be converted to a {@link UnknownFieldSet.Builder} and left that way + * until either {@link #setUnknownFields} or {@link #buildPartial} or {@link #build} is called. + */ + private Object unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance(); + + protected Builder() { + this(null); + } + + protected Builder(BuilderParent builderParent) { + this.builderParent = builderParent; + } + + @Override + public void dispose() { + builderParent = null; + } + + /** Called by the subclass when a message is built. */ + protected void onBuilt() { + if (builderParent != null) { + markClean(); + } + } + + /** + * Called by the subclass or a builder to notify us that a message was built and may be cached + * and therefore invalidations are needed. + */ + @Override + public void markClean() { + this.isClean = true; + } + + /** + * Gets whether invalidations are needed + * + * @return whether invalidations are needed + */ + protected boolean isClean() { + return isClean; + } + + @Override + public BuilderT clone() { + BuilderT builder = (BuilderT) getDefaultInstanceForType().newBuilderForType(); + builder.mergeFrom(buildPartial()); + return builder; + } + + /** + * Called by the initialization and clear code paths to allow subclasses to reset any of their + * builtin fields back to the initial values. + */ + @Override + public BuilderT clear() { + unknownFieldsOrBuilder = UnknownFieldSet.getDefaultInstance(); + onChanged(); + return (BuilderT) this; + } + + /** + * Get the FieldAccessorTable for this type. We can't have the message class pass this in to the + * constructor because of bootstrapping trouble with DescriptorProtos. + */ + protected abstract FieldAccessorTable internalGetFieldAccessorTable(); + + @Override + public Descriptor getDescriptorForType() { + return internalGetFieldAccessorTable().descriptor; + } + + @Override + public Map getAllFields() { + return Collections.unmodifiableMap(getAllFieldsMutable()); + } + + /** Internal helper which returns a mutable map. */ + private Map getAllFieldsMutable() { + final TreeMap result = new TreeMap<>(); + final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; + final List fields = descriptor.getFields(); + + for (int i = 0; i < fields.size(); i++) { + FieldDescriptor field = fields.get(i); + final OneofDescriptor oneofDescriptor = field.getContainingOneof(); + + /* + * If the field is part of a Oneof, then at maximum one field in the Oneof is set + * and it is not repeated. There is no need to iterate through the others. + */ + if (oneofDescriptor != null) { + // Skip other fields in the Oneof we know are not set + i += oneofDescriptor.getFieldCount() - 1; + if (!hasOneof(oneofDescriptor)) { + // If no field is set in the Oneof, skip all the fields in the Oneof + continue; + } + // Get the pointer to the only field which is set in the Oneof + field = getOneofFieldDescriptor(oneofDescriptor); + } else { + // If we are not in a Oneof, we need to check if the field is set and if it is repeated + if (field.isRepeated()) { + final List value = (List) getField(field); + if (!value.isEmpty()) { + result.put(field, value); + } + continue; + } + if (!hasField(field)) { + continue; + } + } + // Add the field to the map + result.put(field, getField(field)); + } + return result; + } + + @Override + public Message.Builder newBuilderForField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).newBuilder(); + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getBuilder(this); + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + return internalGetFieldAccessorTable().getField(field).getRepeatedBuilder(this, index); + } + + @Override + public boolean hasOneof(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).has(this); + } + + @Override + public FieldDescriptor getOneofFieldDescriptor(final OneofDescriptor oneof) { + return internalGetFieldAccessorTable().getOneof(oneof).get(this); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).has(this); + } + + @Override + public Object getField(final FieldDescriptor field) { + Object object = internalGetFieldAccessorTable().getField(field).get(this); + if (field.isRepeated()) { + // The underlying list object is still modifiable at this point. + // Make sure not to expose the modifiable list to the caller. + return Collections.unmodifiableList((List) object); + } else { + return object; + } + } + + @Override + public BuilderT setField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).set(this, value); + return (BuilderT) this; + } + + @Override + public BuilderT clearField(final FieldDescriptor field) { + internalGetFieldAccessorTable().getField(field).clear(this); + return (BuilderT) this; + } + + @Override + public BuilderT clearOneof(final OneofDescriptor oneof) { + internalGetFieldAccessorTable().getOneof(oneof).clear(this); + return (BuilderT) this; + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + return internalGetFieldAccessorTable().getField(field).getRepeatedCount(this); + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + return internalGetFieldAccessorTable().getField(field).getRepeated(this, index); + } + + @Override + public BuilderT setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + internalGetFieldAccessorTable().getField(field).setRepeated(this, index, value); + return (BuilderT) this; + } + + @Override + public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) { + internalGetFieldAccessorTable().getField(field).addRepeated(this, value); + return (BuilderT) this; + } + + private BuilderT setUnknownFieldsInternal(final UnknownFieldSet unknownFields) { + unknownFieldsOrBuilder = unknownFields; + onChanged(); + return (BuilderT) this; + } + + @Override + public BuilderT setUnknownFields(final UnknownFieldSet unknownFields) { + return setUnknownFieldsInternal(unknownFields); + } + + /** + * This method is obsolete, but we must retain it for compatibility with older generated code. + */ + protected BuilderT setUnknownFieldsProto3(final UnknownFieldSet unknownFields) { + return setUnknownFieldsInternal(unknownFields); + } + + @Override + public BuilderT mergeUnknownFields(final UnknownFieldSet unknownFields) { + if (UnknownFieldSet.getDefaultInstance().equals(unknownFields)) { + return (BuilderT) this; + } + + if (UnknownFieldSet.getDefaultInstance().equals(unknownFieldsOrBuilder)) { + unknownFieldsOrBuilder = unknownFields; + onChanged(); + return (BuilderT) this; + } + + getUnknownFieldSetBuilder().mergeFrom(unknownFields); + onChanged(); + return (BuilderT) this; + } + + @Override + public boolean isInitialized() { + for (final FieldDescriptor field : getDescriptorForType().getFields()) { + // Check that all required fields are present. + if (field.isRequired()) { + if (!hasField(field)) { + return false; + } + } + // Check that embedded messages are initialized. + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isRepeated()) { + @SuppressWarnings("unchecked") + final List messageList = (List) getField(field); + for (final Message element : messageList) { + if (!element.isInitialized()) { + return false; + } + } + } else { + if (hasField(field) && !((Message) getField(field)).isInitialized()) { + return false; + } + } + } + } + return true; + } + + @Override + public final UnknownFieldSet getUnknownFields() { + if (unknownFieldsOrBuilder instanceof UnknownFieldSet) { + return (UnknownFieldSet) unknownFieldsOrBuilder; + } else { + return ((UnknownFieldSet.Builder) unknownFieldsOrBuilder).buildPartial(); + } + } + + /** + * Called by generated subclasses to parse an unknown field. + * + * @return {@code true} unless the tag is an end-group tag. + */ + protected boolean parseUnknownField( + CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) + throws IOException { + if (input.shouldDiscardUnknownFields()) { + return input.skipField(tag); + } + return getUnknownFieldSetBuilder().mergeFieldFrom(tag, input); + } + + /** Called by generated subclasses to add to the unknown field set. */ + protected final void mergeUnknownLengthDelimitedField(int number, ByteString bytes) { + getUnknownFieldSetBuilder().mergeLengthDelimitedField(number, bytes); + } + + /** Called by generated subclasses to add to the unknown field set. */ + protected final void mergeUnknownVarintField(int number, int value) { + getUnknownFieldSetBuilder().mergeVarintField(number, value); + } + + @Override + protected UnknownFieldSet.Builder getUnknownFieldSetBuilder() { + if (unknownFieldsOrBuilder instanceof UnknownFieldSet) { + unknownFieldsOrBuilder = ((UnknownFieldSet) unknownFieldsOrBuilder).toBuilder(); + } + onChanged(); + return (UnknownFieldSet.Builder) unknownFieldsOrBuilder; + } + + @Override + protected void setUnknownFieldSetBuilder(UnknownFieldSet.Builder builder) { + unknownFieldsOrBuilder = builder; + onChanged(); + } + + /** + * Implementation of {@link BuilderParent} for giving to our children. This small inner class + * makes it so we don't publicly expose the BuilderParent methods. + */ + private class BuilderParentImpl implements BuilderParent { + + @Override + public void markDirty() { + onChanged(); + } + } + + /** + * Gets the {@link BuilderParent} for giving to our children. + * + * @return The builder parent for our children. + */ + protected BuilderParent getParentForChildren() { + if (meAsParent == null) { + meAsParent = new BuilderParentImpl(); + } + return meAsParent; + } + + /** + * Called when a builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + protected final void onChanged() { + if (isClean && builderParent != null) { + builderParent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but + * the generated API only allows us to access it as a map. This method returns the underlying + * map field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapFieldReflectionAccessor internalGetMapFieldReflection(int fieldNumber) { + return internalGetMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + + /** Like {@link #internalGetMapFieldReflection} but return a mutable version. */ + @SuppressWarnings({"unused", "rawtypes"}) + protected MapFieldReflectionAccessor internalGetMutableMapFieldReflection(int fieldNumber) { + return internalGetMutableMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"unused", "rawtypes"}) + protected MapField internalGetMutableMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + } + + // ================================================================= + // Extensions-related stuff + + /** Extends {@link MessageOrBuilder} with extension-related functions. */ + public interface ExtendableMessageOrBuilder> + extends MessageOrBuilder { + // Re-define for return type covariance. + @Override + Message getDefaultInstanceForType(); + + /** Check if a singular extension is present. */ + boolean hasExtension(ExtensionLite extension); + + /** Get the number of elements in a repeated extension. */ + int getExtensionCount(ExtensionLite> extension); + + /** Get the value of an extension. */ + T getExtension(ExtensionLite extension); + + /** Get one element of a repeated extension. */ + T getExtension(ExtensionLite> extension, int index); + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + boolean hasExtension( + Extension extension); + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + boolean hasExtension( + GeneratedExtension extension); + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + int getExtensionCount( + Extension> extension); + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + int getExtensionCount( + GeneratedExtension> extension); + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + Extension extension); + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + GeneratedExtension extension); + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + Extension> extension, + int index); + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + T getExtension( + GeneratedExtension> extension, + int index); + } + + /** + * Generated message classes for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "has", "get", and "getCount" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo = getFoo();
+   * int i = foo.getExtension(MyProto.bar);
+   * 
+ * + *

See also {@link ExtendableBuilder}. + */ + public abstract static class ExtendableMessage> + extends GeneratedMessageV3Internal implements ExtendableMessageOrBuilder { + + private static final long serialVersionUID = 1L; + + private final FieldSet extensions; + + protected ExtendableMessage() { + this.extensions = FieldSet.newFieldSet(); + } + + protected ExtendableMessage(ExtendableBuilder builder) { + super(builder); + this.extensions = builder.buildExtensions(); + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + @SuppressWarnings("unchecked") + public final T getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (T) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (T) extension.getMessageDefaultInstance(); + } else { + return (T) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (T) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + @SuppressWarnings("unchecked") + public final T getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + return (T) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension( + final GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Get one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions.isInitialized(); + } + + // TODO: compute this in the builder at {@code build()} time. + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + // TODO: remove mutating method from immutable type + @Override + protected boolean parseUnknownField( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return MessageReflection.mergeFieldFrom( + input, + input.shouldDiscardUnknownFields() ? null : unknownFields, + extensionRegistry, + getDescriptorForType(), + new MessageReflection.ExtensionAdapter(extensions), + tag); + } + + /** + * Delegates to parseUnknownField. This method is obsolete, but we must retain it for + * compatibility with older generated code. + * + *

TODO: remove mutating method from immutable type + */ + @Override + protected boolean parseUnknownFieldProto3( + CodedInputStream input, + UnknownFieldSet.Builder unknownFields, + ExtensionRegistryLite extensionRegistry, + int tag) + throws IOException { + return parseUnknownField(input, unknownFields, extensionRegistry, tag); + } + + /** + * Used by parsing constructors in generated classes. + * + *

TODO: remove unused method (extensions should be immutable after build) + */ + @Override + protected void makeExtensionsImmutable() { + extensions.makeImmutable(); + } + + /** + * Used by subclasses to serialize extensions. Extension ranges may be interleaved with field + * numbers, but we must write them in canonical (sorted by field number) order. ExtensionWriter + * helps us write individual ranges of extensions at once. + */ + protected class ExtensionWriter { + // Imagine how much simpler this code would be if Java iterators had + // a way to get the next element without advancing the iterator. + + private final Iterator> iter = extensions.iterator(); + private Map.Entry next; + private final boolean messageSetWireFormat; + + private ExtensionWriter(final boolean messageSetWireFormat) { + if (iter.hasNext()) { + next = iter.next(); + } + this.messageSetWireFormat = messageSetWireFormat; + } + + public void writeUntil(final int end, final CodedOutputStream output) throws IOException { + while (next != null && next.getKey().getNumber() < end) { + FieldDescriptor descriptor = next.getKey(); + if (messageSetWireFormat + && descriptor.getLiteJavaType() == WireFormat.JavaType.MESSAGE + && !descriptor.isRepeated()) { + if (next instanceof LazyField.LazyEntry) { + output.writeRawMessageSetExtension( + descriptor.getNumber(), + ((LazyField.LazyEntry) next).getField().toByteString()); + } else { + output.writeMessageSetExtension(descriptor.getNumber(), (Message) next.getValue()); + } + } else { + // TODO: Taken care of following code, it may cause + // problem when we use LazyField for normal fields/extensions. + // Due to the optional field can be duplicated at the end of + // serialized bytes, which will make the serialized size change + // after lazy field parsed. So when we use LazyField globally, + // we need to change the following write method to write cached + // bytes directly rather than write the parsed message. + FieldSet.writeField(descriptor, next.getValue(), output); + } + if (iter.hasNext()) { + next = iter.next(); + } else { + next = null; + } + } + } + } + + protected ExtensionWriter newExtensionWriter() { + return new ExtensionWriter(false); + } + + protected ExtensionWriter newMessageSetExtensionWriter() { + return new ExtensionWriter(true); + } + + /** Called by subclasses to compute the size of extensions. */ + protected int extensionsSerializedSize() { + return extensions.getSerializedSize(); + } + + protected int extensionsSerializedSizeAsMessageSet() { + return extensions.getMessageSetSerializedSize(); + } + + // --------------------------------------------------------------- + // Reflection + + protected Map getExtensionFields() { + return extensions.getAllFields(); + } + + @Override + public Map getAllFields() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString= */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public Map getAllFieldsRaw() { + final Map result = + super.getAllFieldsMutable(/* getBytesForString= */ false); + result.putAll(getExtensionFields()); + return Collections.unmodifiableMap(result); + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions.getField(field); + if (value == null) { + if (field.isRepeated()) { + return Collections.emptyList(); + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + /** + * Generated message builders for message types that contain extension ranges subclass this. + * + *

This class implements type-safe accessors for extensions. They implement all the same + * operations that you can do with normal fields -- e.g. "get", "set", and "add" -- but for + * extensions. The extensions are identified using instances of the class {@link + * GeneratedExtension}; the protocol compiler generates a static instance of this class for every + * extension in its input. Through the magic of generics, all is made type-safe. + * + *

For example, imagine you have the {@code .proto} file: + * + *

+   * option java_class = "MyProto";
+   *
+   * message Foo {
+   *   extensions 1000 to max;
+   * }
+   *
+   * extend Foo {
+   *   optional int32 bar;
+   * }
+   * 
+ * + *

Then you might write code like: + * + *

+   * MyProto.Foo foo =
+   *   MyProto.Foo.newBuilder()
+   *     .setExtension(MyProto.bar, 123)
+   *     .build();
+   * 
+ * + *

See also {@link ExtendableMessage}. + */ + @SuppressWarnings("unchecked") + public abstract static class ExtendableBuilder< + MessageT extends ExtendableMessage, + BuilderT extends ExtendableBuilder> + extends Builder implements ExtendableMessageOrBuilder { + + private FieldSet.Builder extensions; + + protected ExtendableBuilder() {} + + protected ExtendableBuilder(BuilderParent parent) { + super(parent); + } + + // For immutable message conversion. + void internalSetExtensionSet(FieldSet extensions) { + this.extensions = FieldSet.Builder.fromFieldSet(extensions); + } + + @Override + public BuilderT clear() { + extensions = null; + return super.clear(); + } + + private void ensureExtensionsIsMutable() { + if (extensions == null) { + extensions = FieldSet.newBuilder(); + } + } + + private void verifyExtensionContainingType(final Extension extension) { + if (extension.getDescriptor().getContainingType() != getDescriptorForType()) { + // This can only happen if someone uses unchecked operations. + throw new IllegalArgumentException( + "Extension is for type \"" + + extension.getDescriptor().getContainingType().getFullName() + + "\" which does not match message type \"" + + getDescriptorForType().getFullName() + + "\"."); + } + } + + /** Check if a singular extension is present. */ + @Override + public final boolean hasExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + return extensions != null && extensions.hasField(extension.getDescriptor()); + } + + /** Get the number of elements in a repeated extension. */ + @Override + public final int getExtensionCount(final ExtensionLite> extensionLite) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + final FieldDescriptor descriptor = extension.getDescriptor(); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(descriptor); + } + + /** Get the value of an extension. */ + @Override + public final T getExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + final Object value = extensions == null ? null : extensions.getField(descriptor); + if (value == null) { + if (descriptor.isRepeated()) { + return (T) Collections.emptyList(); + } else if (descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + return (T) extension.getMessageDefaultInstance(); + } else { + return (T) extension.fromReflectionType(descriptor.getDefaultValue()); + } + } else { + return (T) extension.fromReflectionType(value); + } + } + + /** Get one element of a repeated extension. */ + @Override + public final T getExtension( + final ExtensionLite> extensionLite, final int index) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + FieldDescriptor descriptor = extension.getDescriptor(); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } + return (T) + extension.singularFromReflectionType(extensions.getRepeatedField(descriptor, index)); + } + + /** Set the value of an extension. */ + public final BuilderT setExtension( + final ExtensionLite extensionLite, final T value) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setField(descriptor, extension.toReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Set the value of one element of a repeated extension. */ + public final BuilderT setExtension( + final ExtensionLite> extensionLite, final int index, final T value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.setRepeatedField(descriptor, index, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Append a value to a repeated extension. */ + public final BuilderT addExtension( + final ExtensionLite> extensionLite, final T value) { + Extension> extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + final FieldDescriptor descriptor = extension.getDescriptor(); + extensions.addRepeatedField(descriptor, extension.singularToReflectionType(value)); + onChanged(); + return (BuilderT) this; + } + + /** Clear an extension. */ + public final BuilderT clearExtension(final ExtensionLite extensionLite) { + Extension extension = checkNotLite(extensionLite); + + verifyExtensionContainingType(extension); + ensureExtensionsIsMutable(); + extensions.clearField(extension.getDescriptor()); + onChanged(); + return (BuilderT) this; + } + + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension(final Extension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Check if a singular extension is present. + *

TODO: handled by ExtensionLite version + */ + @Override + public final boolean hasExtension( + final GeneratedExtension extension) { + return hasExtension((ExtensionLite) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final Extension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the number of elements in a repeated extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final int getExtensionCount( + final GeneratedExtension> extension) { + return getExtensionCount((ExtensionLite>) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension(final Extension extension) { + return getExtension((ExtensionLite) extension); + } + /** Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension extension) { + return getExtension((ExtensionLite) extension); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final Extension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Get the value of an extension. + *

TODO: handled by ExtensionLite version + */ + @Override + public final T getExtension( + final GeneratedExtension> extension, final int index) { + return getExtension((ExtensionLite>) extension, index); + } + /** + * Set the value of an extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT setExtension( + final Extension extension, final T value) { + return setExtension((ExtensionLite) extension, value); + } + /** + * Set the value of an extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT setExtension( + final GeneratedExtension extension, final T value) { + return setExtension((ExtensionLite) extension, value); + } + /** + * Set the value of one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT setExtension( + final Extension> extension, + final int index, final T value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** + * Set the value of one element of a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT setExtension( + final GeneratedExtension> extension, + final int index, final T value) { + return setExtension((ExtensionLite>) extension, index, value); + } + /** + * Append a value to a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT addExtension( + final Extension> extension, final T value) { + return addExtension((ExtensionLite>) extension, value); + } + /** + * Append a value to a repeated extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT addExtension( + final GeneratedExtension> extension, final T value) { + return addExtension((ExtensionLite>) extension, value); + } + /** + * Clear an extension. + *

TODO: handled by ExtensionLite version + */ + public final BuilderT clearExtension( + final Extension extension) { + return clearExtension((ExtensionLite) extension); + } + /** + * Clears an extension. + *

TODO: handled by ExtensionLite version + */ + public BuilderT clearExtension( + final GeneratedExtension extension) { + return clearExtension((ExtensionLite) extension); + } + + /** Called by subclasses to check if all extensions are initialized. */ + protected boolean extensionsAreInitialized() { + return extensions == null || extensions.isInitialized(); + } + + /** + * Called by the build code path to create a copy of the extensions for building the message. + */ + private FieldSet buildExtensions() { + return extensions == null + ? (FieldSet) FieldSet.emptySet() + : extensions.buildPartial(); + } + + @Override + public boolean isInitialized() { + return super.isInitialized() && extensionsAreInitialized(); + } + + // --------------------------------------------------------------- + // Reflection + + @Override + public Map getAllFields() { + final Map result = super.getAllFieldsMutable(); + if (extensions != null) { + result.putAll(extensions.getAllFields()); + } + return Collections.unmodifiableMap(result); + } + + @Override + public Object getField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + final Object value = extensions == null ? null : extensions.getField(field); + if (value == null) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + // Lacking an ExtensionRegistry, we have no way to determine the + // extension's real type, so we return a DynamicMessage. + return DynamicMessage.getDefaultInstance(field.getMessageType()); + } else { + return field.getDefaultValue(); + } + } else { + return value; + } + } else { + return super.getField(field); + } + } + + @Override + public Message.Builder getFieldBuilder(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on a non-Message type."); + } + ensureExtensionsIsMutable(); + final Object value = extensions.getFieldAllowBuilders(field); + if (value == null) { + Message.Builder builder = DynamicMessage.newBuilder(field.getMessageType()); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setField(field, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + } else { + return super.getFieldBuilder(field); + } + } + + @Override + public int getRepeatedFieldCount(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions == null ? 0 : extensions.getRepeatedFieldCount(field); + } else { + return super.getRepeatedFieldCount(field); + } + } + + @Override + public Object getRepeatedField(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + if (extensions == null) { + throw new IndexOutOfBoundsException(); + } + return extensions.getRepeatedField(field, index); + } else { + return super.getRepeatedField(field, index); + } + } + + @Override + public Message.Builder getRepeatedFieldBuilder(final FieldDescriptor field, final int index) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + if (field.getJavaType() != FieldDescriptor.JavaType.MESSAGE) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + final Object value = extensions.getRepeatedFieldAllowBuilders(field, index); + if (value instanceof Message.Builder) { + return (Message.Builder) value; + } else if (value instanceof Message) { + Message.Builder builder = ((Message) value).toBuilder(); + extensions.setRepeatedField(field, index, builder); + onChanged(); + return builder; + } else { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } else { + return super.getRepeatedFieldBuilder(field, index); + } + } + + @Override + public boolean hasField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + return extensions != null && extensions.hasField(field); + } else { + return super.hasField(field); + } + } + + @Override + public BuilderT setField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setField(field, value); + onChanged(); + return (BuilderT) this; + } else { + return super.setField(field, value); + } + } + + @Override + public BuilderT clearField(final FieldDescriptor field) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.clearField(field); + onChanged(); + return (BuilderT) this; + } else { + return super.clearField(field); + } + } + + @Override + public BuilderT setRepeatedField( + final FieldDescriptor field, final int index, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.setRepeatedField(field, index, value); + onChanged(); + return (BuilderT) this; + } else { + return super.setRepeatedField(field, index, value); + } + } + + @Override + public BuilderT addRepeatedField(final FieldDescriptor field, final Object value) { + if (field.isExtension()) { + verifyContainingType(field); + ensureExtensionsIsMutable(); + extensions.addRepeatedField(field, value); + onChanged(); + return (BuilderT) this; + } else { + return super.addRepeatedField(field, value); + } + } + + @Override + public Message.Builder newBuilderForField(final FieldDescriptor field) { + if (field.isExtension()) { + return DynamicMessage.newBuilder(field.getMessageType()); + } else { + return super.newBuilderForField(field); + } + } + + protected final void mergeExtensionFields(final ExtendableMessage other) { + if (other.extensions != null) { + ensureExtensionsIsMutable(); + extensions.mergeFrom(other.extensions); + onChanged(); + } + } + + @Override + protected boolean parseUnknownField( + CodedInputStream input, ExtensionRegistryLite extensionRegistry, int tag) + throws IOException { + ensureExtensionsIsMutable(); + return MessageReflection.mergeFieldFrom( + input, + input.shouldDiscardUnknownFields() ? null : getUnknownFieldSetBuilder(), + extensionRegistry, + getDescriptorForType(), + new MessageReflection.ExtensionBuilderAdapter(extensions), + tag); + } + + private void verifyContainingType(final FieldDescriptor field) { + if (field.getContainingType() != getDescriptorForType()) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } + } + } + + // ----------------------------------------------------------------- + + /** + * Gets the descriptor for an extension. The implementation depends on whether the extension is + * scoped in the top level of a file or scoped in a Message. + */ + interface ExtensionDescriptorRetriever { + FieldDescriptor getDescriptor(); + } + + // ================================================================= + + /** Calls Class.getMethod and throws a RuntimeException if it fails. */ + private static Method getMethodOrDie( + final Class clazz, final String name, final Class... params) { + try { + return clazz.getMethod(name, params); + } catch (NoSuchMethodException e) { + throw new IllegalStateException( + "Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".", + e); + } + } + + /** Calls invoke and throws a RuntimeException if it fails. */ + @CanIgnoreReturnValue + private static Object invokeOrDie( + final Method method, final Object object, final Object... params) { + try { + return method.invoke(object, params); + } catch (IllegalAccessException e) { + throw new IllegalStateException( + "Couldn't use Java reflection to implement protocol message reflection.", e); + } catch (InvocationTargetException e) { + final Throwable cause = e.getCause(); + if (cause instanceof RuntimeException) { + throw (RuntimeException) cause; + } else if (cause instanceof Error) { + throw (Error) cause; + } else { + throw new IllegalStateException( + "Unexpected exception thrown by generated accessor method.", cause); + } + } + } + + /** + * Gets the map field with the given field number. This method should be overridden in the + * generated message class if the message contains map fields. + * + *

Unlike other field types, reflection support for map fields can't be implemented based on + * generated public API because we need to access a map field as a list in reflection API but the + * generated API only allows us to access it as a map. This method returns the underlying map + * field directly and thus enables us to access the map field as a list. + */ + @SuppressWarnings("unused") + protected MapFieldReflectionAccessor internalGetMapFieldReflection(int fieldNumber) { + return internalGetMapField(fieldNumber); + } + + /** TODO: Remove, exists for compatibility with generated code. */ + @Deprecated + @SuppressWarnings({"rawtypes", "unused"}) + protected MapField internalGetMapField(int fieldNumber) { + // Note that we can't use descriptor names here because this method will + // be called when descriptor is being initialized. + throw new IllegalArgumentException("No map fields found in " + getClass().getName()); + } + + /** + * Users should ignore this class. This class provides the implementation with access to the + * fields of a message object using Java reflection. + */ + public static final class FieldAccessorTable { + + /** + * Construct a FieldAccessorTable for a particular message class. Only one FieldAccessorTable + * should ever be constructed per class. + * + * @param descriptor The type's descriptor. + * @param camelCaseNames The camelcase names of all fields in the message. These are used to + * derive the accessor method names. + * @param messageClass The message type. + * @param builderClass The builder type. + */ + public FieldAccessorTable( + final Descriptor descriptor, + final String[] camelCaseNames, + final Class messageClass, + final Class> builderClass) { + this(descriptor, camelCaseNames); + ensureFieldAccessorsInitialized(messageClass, builderClass); + } + + /** + * Construct a FieldAccessorTable for a particular message class without initializing + * FieldAccessors. + */ + public FieldAccessorTable(final Descriptor descriptor, final String[] camelCaseNames) { + this.descriptor = descriptor; + this.camelCaseNames = camelCaseNames; + fields = new FieldAccessor[descriptor.getFields().size()]; + oneofs = new OneofAccessor[descriptor.getOneofs().size()]; + initialized = false; + } + + /** + * Ensures the field accessors are initialized. This method is thread-safe. + * + * @param messageClass The message type. + * @param builderClass The builder type. + * @return this + */ + public FieldAccessorTable ensureFieldAccessorsInitialized( + Class messageClass, Class> builderClass) { + if (initialized) { + return this; + } + synchronized (this) { + if (initialized) { + return this; + } + int fieldsSize = fields.length; + for (int i = 0; i < fieldsSize; i++) { + FieldDescriptor field = descriptor.getFields().get(i); + String containingOneofCamelCaseName = null; + if (field.getContainingOneof() != null) { + int index = fieldsSize + field.getContainingOneof().getIndex(); + if (index < camelCaseNames.length) { + containingOneofCamelCaseName = camelCaseNames[index]; + } + } + if (field.isRepeated()) { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + if (field.isMapField()) { + fields[i] = new MapFieldAccessor(field, messageClass); + } else { + fields[i] = + new RepeatedMessageFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new RepeatedEnumFieldAccessor( + field, camelCaseNames[i], messageClass, builderClass); + } else { + fields[i] = + new RepeatedFieldAccessor(field, camelCaseNames[i], messageClass, builderClass); + } + } else { + if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + fields[i] = + new SingularMessageFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.ENUM) { + fields[i] = + new SingularEnumFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else if (field.getJavaType() == FieldDescriptor.JavaType.STRING) { + fields[i] = + new SingularStringFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } else { + fields[i] = + new SingularFieldAccessor( + field, + camelCaseNames[i], + messageClass, + builderClass, + containingOneofCamelCaseName); + } + } + } + + for (int i = 0; i < descriptor.getOneofs().size(); i++) { + if (i < descriptor.getRealOneofs().size()) { + oneofs[i] = + new RealOneofAccessor( + descriptor, i, camelCaseNames[i + fieldsSize], messageClass, builderClass); + } else { + oneofs[i] = new SyntheticOneofAccessor(descriptor, i); + } + } + + initialized = true; + camelCaseNames = null; + return this; + } + } + + private final Descriptor descriptor; + private final FieldAccessor[] fields; + private String[] camelCaseNames; + private final OneofAccessor[] oneofs; + private volatile boolean initialized; + + /** Get the FieldAccessor for a particular field. */ + private FieldAccessor getField(final FieldDescriptor field) { + if (field.getContainingType() != descriptor) { + throw new IllegalArgumentException("FieldDescriptor does not match message type."); + } else if (field.isExtension()) { + // If this type had extensions, it would subclass ExtendableMessage, + // which overrides the reflection interface to handle extensions. + throw new IllegalArgumentException("This type does not have extensions."); + } + return fields[field.getIndex()]; + } + + /** Get the OneofAccessor for a particular oneof. */ + private OneofAccessor getOneof(final OneofDescriptor oneof) { + if (oneof.getContainingType() != descriptor) { + throw new IllegalArgumentException("OneofDescriptor does not match message type."); + } + return oneofs[oneof.getIndex()]; + } + + /** + * Abstract interface that provides access to a single field. This is implemented differently + * depending on the field type and cardinality. + */ + private interface FieldAccessor { + Object get(GeneratedMessageV3Internal message); + + Object get(GeneratedMessageV3Internal.Builder builder); + + Object getRaw(GeneratedMessageV3Internal message); + + void set(Builder builder, Object value); + + Object getRepeated(GeneratedMessageV3Internal message, int index); + + Object getRepeated(GeneratedMessageV3Internal.Builder builder, int index); + + void setRepeated(Builder builder, int index, Object value); + + void addRepeated(Builder builder, Object value); + + boolean has(GeneratedMessageV3Internal message); + + boolean has(GeneratedMessageV3Internal.Builder builder); + + int getRepeatedCount(GeneratedMessageV3Internal message); + + int getRepeatedCount(GeneratedMessageV3Internal.Builder builder); + + void clear(Builder builder); + + Message.Builder newBuilder(); + + Message.Builder getBuilder(GeneratedMessageV3Internal.Builder builder); + + Message.Builder getRepeatedBuilder(GeneratedMessageV3Internal.Builder builder, int index); + } + + /** OneofAccessor provides access to a single oneof. */ + private static interface OneofAccessor { + public boolean has(final GeneratedMessageV3Internal message); + + public boolean has(GeneratedMessageV3Internal.Builder builder); + + public FieldDescriptor get(final GeneratedMessageV3Internal message); + + public FieldDescriptor get(GeneratedMessageV3Internal.Builder builder); + + public void clear(final Builder builder); + } + + /** RealOneofAccessor provides access to a single real oneof. */ + private static class RealOneofAccessor implements OneofAccessor { + RealOneofAccessor( + final Descriptor descriptor, + final int oneofIndex, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + this.descriptor = descriptor; + caseMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Case"); + caseMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Case"); + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + private final Descriptor descriptor; + private final Method caseMethod; + private final Method caseMethodBuilder; + private final Method clearMethod; + + @Override + public boolean has(final GeneratedMessageV3Internal message) { + return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber() != 0; + } + + @Override + public boolean has(GeneratedMessageV3Internal.Builder builder) { + return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber() != 0; + } + + @Override + public FieldDescriptor get(final GeneratedMessageV3Internal message) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + @Override + public FieldDescriptor get(GeneratedMessageV3Internal.Builder builder) { + int fieldNumber = ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + if (fieldNumber > 0) { + return descriptor.findFieldByNumber(fieldNumber); + } + return null; + } + + @Override + public void clear(final Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + /** SyntheticOneofAccessor provides access to a single synthetic oneof. */ + private static class SyntheticOneofAccessor implements OneofAccessor { + SyntheticOneofAccessor(final Descriptor descriptor, final int oneofIndex) { + OneofDescriptor oneofDescriptor = descriptor.getOneofs().get(oneofIndex); + fieldDescriptor = oneofDescriptor.getFields().get(0); + } + + private final FieldDescriptor fieldDescriptor; + + @Override + public boolean has(final GeneratedMessageV3Internal message) { + return message.hasField(fieldDescriptor); + } + + @Override + public boolean has(GeneratedMessageV3Internal.Builder builder) { + return builder.hasField(fieldDescriptor); + } + + @Override + public FieldDescriptor get(final GeneratedMessageV3Internal message) { + return message.hasField(fieldDescriptor) ? fieldDescriptor : null; + } + + public FieldDescriptor get(GeneratedMessageV3Internal.Builder builder) { + return builder.hasField(fieldDescriptor) ? fieldDescriptor : null; + } + + @Override + public void clear(final Builder builder) { + builder.clearField(fieldDescriptor); + } + } + + // --------------------------------------------------------------- + + @SuppressWarnings("SameNameButDifferent") + private static class SingularFieldAccessor implements FieldAccessor { + private interface MethodInvoker { + Object get(final GeneratedMessageV3Internal message); + + Object get(GeneratedMessageV3Internal.Builder builder); + + int getOneofFieldNumber(final GeneratedMessageV3Internal message); + + int getOneofFieldNumber(final GeneratedMessageV3Internal.Builder builder); + + void set(final GeneratedMessageV3Internal.Builder builder, final Object value); + + boolean has(final GeneratedMessageV3Internal message); + + boolean has(GeneratedMessageV3Internal.Builder builder); + + void clear(final GeneratedMessageV3Internal.Builder builder); + } + + private static final class ReflectionInvoker implements MethodInvoker { + private final Method getMethod; + private final Method getMethodBuilder; + private final Method setMethod; + private final Method hasMethod; + private final Method hasMethodBuilder; + private final Method clearMethod; + private final Method caseMethod; + private final Method caseMethodBuilder; + + ReflectionInvoker( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName, + boolean isOneofField, + boolean hasHasMethod) { + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName); + Class type = getMethod.getReturnType(); + setMethod = getMethodOrDie(builderClass, "set" + camelCaseName, type); + hasMethod = hasHasMethod ? getMethodOrDie(messageClass, "has" + camelCaseName) : null; + hasMethodBuilder = + hasHasMethod ? getMethodOrDie(builderClass, "has" + camelCaseName) : null; + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + caseMethod = + isOneofField + ? getMethodOrDie(messageClass, "get" + containingOneofCamelCaseName + "Case") + : null; + caseMethodBuilder = + isOneofField + ? getMethodOrDie(builderClass, "get" + containingOneofCamelCaseName + "Case") + : null; + } + + @Override + public Object get(final GeneratedMessageV3Internal message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(GeneratedMessageV3Internal.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public int getOneofFieldNumber(final GeneratedMessageV3Internal message) { + return ((Internal.EnumLite) invokeOrDie(caseMethod, message)).getNumber(); + } + + @Override + public int getOneofFieldNumber(final GeneratedMessageV3Internal.Builder builder) { + return ((Internal.EnumLite) invokeOrDie(caseMethodBuilder, builder)).getNumber(); + } + + @Override + public void set(final GeneratedMessageV3Internal.Builder builder, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setMethod, builder, value); + } + + @Override + public boolean has(final GeneratedMessageV3Internal message) { + return (Boolean) invokeOrDie(hasMethod, message); + } + + @Override + public boolean has(GeneratedMessageV3Internal.Builder builder) { + return (Boolean) invokeOrDie(hasMethodBuilder, builder); + } + + @Override + public void clear(final GeneratedMessageV3Internal.Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + SingularFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + isOneofField = + descriptor.getRealContainingOneof() != null; + hasHasMethod = + descriptor.getFile().getSyntax() == FileDescriptor.Syntax.EDITIONS && descriptor.hasPresence() + || descriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO2 + || descriptor.hasOptionalKeyword() + || (!isOneofField && descriptor.getJavaType() == FieldDescriptor.JavaType.MESSAGE); + ReflectionInvoker reflectionInvoker = + new ReflectionInvoker( + descriptor, + camelCaseName, + messageClass, + builderClass, + containingOneofCamelCaseName, + isOneofField, + hasHasMethod); + field = descriptor; + type = reflectionInvoker.getMethod.getReturnType(); + invoker = getMethodInvoker(reflectionInvoker); + } + + static MethodInvoker getMethodInvoker(ReflectionInvoker accessor) { + return accessor; + } + + // Note: We use Java reflection to call public methods rather than + // access private fields directly as this avoids runtime security + // checks. + protected final Class type; + protected final FieldDescriptor field; + protected final boolean isOneofField; + protected final boolean hasHasMethod; + protected final MethodInvoker invoker; + + @Override + public Object get(final GeneratedMessageV3Internal message) { + return invoker.get(message); + } + + @Override + public Object get(GeneratedMessageV3Internal.Builder builder) { + return invoker.get(builder); + } + + @Override + public Object getRaw(final GeneratedMessageV3Internal message) { + return get(message); + } + + @Override + public void set(final Builder builder, final Object value) { + invoker.set(builder, value); + } + + @Override + public Object getRepeated(final GeneratedMessageV3Internal message, final int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public Object getRepeated(GeneratedMessageV3Internal.Builder builder, int index) { + throw new UnsupportedOperationException("getRepeatedField() called on a singular field."); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + throw new UnsupportedOperationException("setRepeatedField() called on a singular field."); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + throw new UnsupportedOperationException("addRepeatedField() called on a singular field."); + } + + @Override + public boolean has(final GeneratedMessageV3Internal message) { + if (!hasHasMethod) { + if (isOneofField) { + return invoker.getOneofFieldNumber(message) == field.getNumber(); + } + return !get(message).equals(field.getDefaultValue()); + } + return invoker.has(message); + } + + @Override + public boolean has(GeneratedMessageV3Internal.Builder builder) { + if (!hasHasMethod) { + if (isOneofField) { + return invoker.getOneofFieldNumber(builder) == field.getNumber(); + } + return !get(builder).equals(field.getDefaultValue()); + } + return invoker.has(builder); + } + + @Override + public int getRepeatedCount(final GeneratedMessageV3Internal message) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public int getRepeatedCount(GeneratedMessageV3Internal.Builder builder) { + throw new UnsupportedOperationException( + "getRepeatedFieldSize() called on a singular field."); + } + + @Override + public void clear(final Builder builder) { + invoker.clear(builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageV3Internal.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(GeneratedMessageV3Internal.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + @SuppressWarnings("SameNameButDifferent") + private static class RepeatedFieldAccessor implements FieldAccessor { + interface MethodInvoker { + Object get(final GeneratedMessageV3Internal message); + + Object get(GeneratedMessageV3Internal.Builder builder); + + Object getRepeated(final GeneratedMessageV3Internal message, final int index); + + Object getRepeated(GeneratedMessageV3Internal.Builder builder, int index); + + void setRepeated( + final GeneratedMessageV3Internal.Builder builder, final int index, final Object value); + + void addRepeated(final GeneratedMessageV3Internal.Builder builder, final Object value); + + int getRepeatedCount(final GeneratedMessageV3Internal message); + + int getRepeatedCount(GeneratedMessageV3Internal.Builder builder); + + void clear(final GeneratedMessageV3Internal.Builder builder); + } + + private static final class ReflectionInvoker implements MethodInvoker { + private final Method getMethod; + private final Method getMethodBuilder; + private final Method getRepeatedMethod; + private final Method getRepeatedMethodBuilder; + private final Method setRepeatedMethod; + private final Method addRepeatedMethod; + private final Method getCountMethod; + private final Method getCountMethodBuilder; + private final Method clearMethod; + + ReflectionInvoker( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + getMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "List"); + getMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "List"); + getRepeatedMethod = getMethodOrDie(messageClass, "get" + camelCaseName, Integer.TYPE); + getRepeatedMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName, Integer.TYPE); + Class type = getRepeatedMethod.getReturnType(); + setRepeatedMethod = + getMethodOrDie(builderClass, "set" + camelCaseName, Integer.TYPE, type); + addRepeatedMethod = getMethodOrDie(builderClass, "add" + camelCaseName, type); + getCountMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Count"); + getCountMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Count"); + clearMethod = getMethodOrDie(builderClass, "clear" + camelCaseName); + } + + @Override + public Object get(final GeneratedMessageV3Internal message) { + return invokeOrDie(getMethod, message); + } + + @Override + public Object get(GeneratedMessageV3Internal.Builder builder) { + return invokeOrDie(getMethodBuilder, builder); + } + + @Override + public Object getRepeated(final GeneratedMessageV3Internal message, final int index) { + return invokeOrDie(getRepeatedMethod, message, index); + } + + @Override + public Object getRepeated(GeneratedMessageV3Internal.Builder builder, int index) { + return invokeOrDie(getRepeatedMethodBuilder, builder, index); + } + + @Override + public void setRepeated( + final GeneratedMessageV3Internal.Builder builder, final int index, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setRepeatedMethod, builder, index, value); + } + + @Override + public void addRepeated(final GeneratedMessageV3Internal.Builder builder, final Object value) { + // TODO: remove the unused variable + Object unused = invokeOrDie(addRepeatedMethod, builder, value); + } + + @Override + public int getRepeatedCount(final GeneratedMessageV3Internal message) { + return (Integer) invokeOrDie(getCountMethod, message); + } + + @Override + public int getRepeatedCount(GeneratedMessageV3Internal.Builder builder) { + return (Integer) invokeOrDie(getCountMethodBuilder, builder); + } + + @Override + public void clear(final GeneratedMessageV3Internal.Builder builder) { + // TODO: remove the unused variable + Object unused = invokeOrDie(clearMethod, builder); + } + } + + protected final Class type; + protected final MethodInvoker invoker; + + RepeatedFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + ReflectionInvoker reflectionInvoker = + new ReflectionInvoker(descriptor, camelCaseName, messageClass, builderClass); + type = reflectionInvoker.getRepeatedMethod.getReturnType(); + invoker = getMethodInvoker(reflectionInvoker); + } + + static MethodInvoker getMethodInvoker(ReflectionInvoker accessor) { + return accessor; + } + + @Override + public Object get(final GeneratedMessageV3Internal message) { + return invoker.get(message); + } + + @Override + public Object get(GeneratedMessageV3Internal.Builder builder) { + return invoker.get(builder); + } + + @Override + public Object getRaw(final GeneratedMessageV3Internal message) { + return get(message); + } + + @Override + public void set(final Builder builder, final Object value) { + // Add all the elements individually. This serves two purposes: + // 1) Verifies that each element has the correct type. + // 2) Insures that the caller cannot modify the list later on and + // have the modifications be reflected in the message. + clear(builder); + for (final Object element : (List) value) { + addRepeated(builder, element); + } + } + + @Override + public Object getRepeated(final GeneratedMessageV3Internal message, final int index) { + return invoker.getRepeated(message, index); + } + + @Override + public Object getRepeated(GeneratedMessageV3Internal.Builder builder, int index) { + return invoker.getRepeated(builder, index); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + invoker.setRepeated(builder, index, value); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + invoker.addRepeated(builder, value); + } + + @Override + public boolean has(final GeneratedMessageV3Internal message) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public boolean has(GeneratedMessageV3Internal.Builder builder) { + throw new UnsupportedOperationException("hasField() called on a repeated field."); + } + + @Override + public int getRepeatedCount(final GeneratedMessageV3Internal message) { + return invoker.getRepeatedCount(message); + } + + @Override + public int getRepeatedCount(GeneratedMessageV3Internal.Builder builder) { + return invoker.getRepeatedCount(builder); + } + + @Override + public void clear(final Builder builder) { + invoker.clear(builder); + } + + @Override + public Message.Builder newBuilder() { + throw new UnsupportedOperationException( + "newBuilderForField() called on a non-Message type."); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageV3Internal.Builder builder) { + throw new UnsupportedOperationException("getFieldBuilder() called on a non-Message type."); + } + + @Override + public Message.Builder getRepeatedBuilder(GeneratedMessageV3Internal.Builder builder, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on a non-Message type."); + } + } + + private static class MapFieldAccessor implements FieldAccessor { + MapFieldAccessor( + final FieldDescriptor descriptor, final Class messageClass) { + field = descriptor; + Method getDefaultInstanceMethod = getMethodOrDie(messageClass, "getDefaultInstance"); + MapFieldReflectionAccessor defaultMapField = + getMapField((GeneratedMessageV3Internal) invokeOrDie(getDefaultInstanceMethod, null)); + mapEntryMessageDefaultInstance = defaultMapField.getMapEntryMessageDefaultInstance(); + } + + private final FieldDescriptor field; + private final Message mapEntryMessageDefaultInstance; + + private MapFieldReflectionAccessor getMapField(GeneratedMessageV3Internal message) { + return message.internalGetMapFieldReflection(field.getNumber()); + } + + private MapFieldReflectionAccessor getMapField(GeneratedMessageV3Internal.Builder builder) { + return builder.internalGetMapFieldReflection(field.getNumber()); + } + + private MapFieldReflectionAccessor getMutableMapField(GeneratedMessageV3Internal.Builder builder) { + return builder.internalGetMutableMapFieldReflection(field.getNumber()); + } + + private Message coerceType(Message value) { + if (value == null) { + return null; + } + if (mapEntryMessageDefaultInstance.getClass().isInstance(value)) { + return value; + } + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return mapEntryMessageDefaultInstance.toBuilder().mergeFrom(value).build(); + } + + @Override + public Object get(GeneratedMessageV3Internal message) { + List result = new ArrayList<>(); + for (int i = 0; i < getRepeatedCount(message); i++) { + result.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + public Object get(Builder builder) { + List result = new ArrayList<>(); + for (int i = 0; i < getRepeatedCount(builder); i++) { + result.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(result); + } + + @Override + public Object getRaw(GeneratedMessageV3Internal message) { + return get(message); + } + + @Override + public void set(Builder builder, Object value) { + clear(builder); + for (Object entry : (List) value) { + addRepeated(builder, entry); + } + } + + @Override + public Object getRepeated(GeneratedMessageV3Internal message, int index) { + return getMapField(message).getList().get(index); + } + + @Override + public Object getRepeated(Builder builder, int index) { + return getMapField(builder).getList().get(index); + } + + @Override + public void setRepeated(Builder builder, int index, Object value) { + getMutableMapField(builder).getMutableList().set(index, coerceType((Message) value)); + } + + @Override + public void addRepeated(Builder builder, Object value) { + getMutableMapField(builder).getMutableList().add(coerceType((Message) value)); + } + + @Override + public boolean has(GeneratedMessageV3Internal message) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public boolean has(Builder builder) { + throw new UnsupportedOperationException("hasField() is not supported for repeated fields."); + } + + @Override + public int getRepeatedCount(GeneratedMessageV3Internal message) { + return getMapField(message).getList().size(); + } + + @Override + public int getRepeatedCount(Builder builder) { + return getMapField(builder).getList().size(); + } + + @Override + public void clear(Builder builder) { + getMutableMapField(builder).getMutableList().clear(); + } + + @Override + public Message.Builder newBuilder() { + return mapEntryMessageDefaultInstance.newBuilderForType(); + } + + @Override + public Message.Builder getBuilder(Builder builder) { + throw new UnsupportedOperationException("Nested builder not supported for map fields."); + } + + @Override + public Message.Builder getRepeatedBuilder(Builder builder, int index) { + throw new UnsupportedOperationException("Map fields cannot be repeated"); + } + } + + // --------------------------------------------------------------- + + private static final class SingularEnumFieldAccessor extends SingularFieldAccessor { + SingularEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getValueMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Value"); + getValueMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Value"); + setValueMethod = getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class); + } + } + + private final EnumDescriptor enumDescriptor; + + private final Method valueOfMethod; + private final Method getValueDescriptorMethod; + + private final boolean supportUnknownEnumValue; + private Method getValueMethod; + private Method getValueMethodBuilder; + private Method setValueMethod; + + @Override + public Object get(final GeneratedMessageV3Internal message) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethod, message); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(message)); + } + + @Override + public Object get(final GeneratedMessageV3Internal.Builder builder) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getValueMethodBuilder, builder); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.get(builder)); + } + + @Override + public void set(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie(setValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.set(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + private static final class RepeatedEnumFieldAccessor extends RepeatedFieldAccessor { + RepeatedEnumFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + enumDescriptor = descriptor.getEnumType(); + + valueOfMethod = getMethodOrDie(type, "valueOf", EnumValueDescriptor.class); + getValueDescriptorMethod = getMethodOrDie(type, "getValueDescriptor"); + + supportUnknownEnumValue = !descriptor.legacyEnumFieldTreatedAsClosed(); + if (supportUnknownEnumValue) { + getRepeatedValueMethod = + getMethodOrDie(messageClass, "get" + camelCaseName + "Value", int.class); + getRepeatedValueMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Value", int.class); + setRepeatedValueMethod = + getMethodOrDie(builderClass, "set" + camelCaseName + "Value", int.class, int.class); + addRepeatedValueMethod = + getMethodOrDie(builderClass, "add" + camelCaseName + "Value", int.class); + } + } + + private final EnumDescriptor enumDescriptor; + + private final Method valueOfMethod; + private final Method getValueDescriptorMethod; + + private final boolean supportUnknownEnumValue; + + private Method getRepeatedValueMethod; + private Method getRepeatedValueMethodBuilder; + private Method setRepeatedValueMethod; + private Method addRepeatedValueMethod; + + @Override + public Object get(final GeneratedMessageV3Internal message) { + final List newList = new ArrayList<>(); + final int size = getRepeatedCount(message); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(message, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + public Object get(final GeneratedMessageV3Internal.Builder builder) { + final List newList = new ArrayList<>(); + final int size = getRepeatedCount(builder); + for (int i = 0; i < size; i++) { + newList.add(getRepeated(builder, i)); + } + return Collections.unmodifiableList(newList); + } + + @Override + public Object getRepeated(final GeneratedMessageV3Internal message, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethod, message, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(message, index)); + } + + @Override + public Object getRepeated(final GeneratedMessageV3Internal.Builder builder, final int index) { + if (supportUnknownEnumValue) { + int value = (Integer) invokeOrDie(getRepeatedValueMethodBuilder, builder, index); + return enumDescriptor.findValueByNumberCreatingIfUnknown(value); + } + return invokeOrDie(getValueDescriptorMethod, super.getRepeated(builder, index)); + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie( + setRepeatedValueMethod, + builder, + index, + ((EnumValueDescriptor) value).getNumber()); + return; + } + super.setRepeated(builder, index, invokeOrDie(valueOfMethod, null, value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + if (supportUnknownEnumValue) { + // TODO: remove the unused variable + Object unused = + invokeOrDie( + addRepeatedValueMethod, builder, ((EnumValueDescriptor) value).getNumber()); + return; + } + super.addRepeated(builder, invokeOrDie(valueOfMethod, null, value)); + } + } + + // --------------------------------------------------------------- + + /** + * Field accessor for string fields. + * + *

This class makes getFooBytes() and setFooBytes() available for reflection API so that + * reflection based serialize/parse functions can access the raw bytes of the field to preserve + * non-UTF8 bytes in the string. + * + *

This ensures the serialize/parse round-trip safety, which is important for servers which + * forward messages. + */ + private static final class SingularStringFieldAccessor extends SingularFieldAccessor { + SingularStringFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + getBytesMethod = getMethodOrDie(messageClass, "get" + camelCaseName + "Bytes"); + setBytesMethodBuilder = + getMethodOrDie(builderClass, "set" + camelCaseName + "Bytes", ByteString.class); + } + + private final Method getBytesMethod; + private final Method setBytesMethodBuilder; + + @Override + public Object getRaw(final GeneratedMessageV3Internal message) { + return invokeOrDie(getBytesMethod, message); + } + + @Override + public void set(GeneratedMessageV3Internal.Builder builder, Object value) { + if (value instanceof ByteString) { + // TODO: remove the unused variable + Object unused = invokeOrDie(setBytesMethodBuilder, builder, value); + } else { + super.set(builder, value); + } + } + } + + // --------------------------------------------------------------- + + private static final class SingularMessageFieldAccessor extends SingularFieldAccessor { + SingularMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass, + final String containingOneofCamelCaseName) { + super(descriptor, camelCaseName, messageClass, builderClass, containingOneofCamelCaseName); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = getMethodOrDie(builderClass, "get" + camelCaseName + "Builder"); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .buildPartial(); + } + } + + @Override + public void set(final Builder builder, final Object value) { + super.set(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getBuilder(GeneratedMessageV3Internal.Builder builder) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder); + } + } + + private static final class RepeatedMessageFieldAccessor extends RepeatedFieldAccessor { + RepeatedMessageFieldAccessor( + final FieldDescriptor descriptor, + final String camelCaseName, + final Class messageClass, + final Class> builderClass) { + super(descriptor, camelCaseName, messageClass, builderClass); + + newBuilderMethod = getMethodOrDie(type, "newBuilder"); + getBuilderMethodBuilder = + getMethodOrDie(builderClass, "get" + camelCaseName + "Builder", Integer.TYPE); + } + + private final Method newBuilderMethod; + private final Method getBuilderMethodBuilder; + + private Object coerceType(final Object value) { + if (type.isInstance(value)) { + return value; + } else { + // The value is not the exact right message type. However, if it + // is an alternative implementation of the same type -- e.g. a + // DynamicMessage -- we should accept it. In this case we can make + // a copy of the message. + return ((Message.Builder) invokeOrDie(newBuilderMethod, null)) + .mergeFrom((Message) value) + .build(); + } + } + + @Override + public void setRepeated(final Builder builder, final int index, final Object value) { + super.setRepeated(builder, index, coerceType(value)); + } + + @Override + public void addRepeated(final Builder builder, final Object value) { + super.addRepeated(builder, coerceType(value)); + } + + @Override + public Message.Builder newBuilder() { + return (Message.Builder) invokeOrDie(newBuilderMethod, null); + } + + @Override + public Message.Builder getRepeatedBuilder( + final GeneratedMessageV3Internal.Builder builder, final int index) { + return (Message.Builder) invokeOrDie(getBuilderMethodBuilder, builder, index); + } + } + } + + /** + * Replaces this object in the output stream with a serialized form. Part of Java's serialization + * magic. Generated sub-classes must override this method by calling {@code return + * super.writeReplace();} + * + * @return a SerializedForm of this message + */ + protected Object writeReplace() throws ObjectStreamException { + return new SerializedForm(this); + } + + /** + * Checks that the {@link Extension} is non-Lite and returns it as a {@link GeneratedExtension}. + */ + private static , T> + Extension checkNotLite(ExtensionLite extension) { + if (extension.isLite()) { + throw new IllegalArgumentException("Expected non-lite extension."); + } + + return (Extension) extension; + } + + protected static boolean isStringEmpty(final Object value) { + if (value instanceof String) { + return ((String) value).isEmpty(); + } else { + return ((ByteString) value).isEmpty(); + } + } + + protected static int computeStringSize(final int fieldNumber, final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSize(fieldNumber, (String) value); + } else { + return CodedOutputStream.computeBytesSize(fieldNumber, (ByteString) value); + } + } + + protected static int computeStringSizeNoTag(final Object value) { + if (value instanceof String) { + return CodedOutputStream.computeStringSizeNoTag((String) value); + } else { + return CodedOutputStream.computeBytesSizeNoTag((ByteString) value); + } + } + + protected static void writeString( + CodedOutputStream output, final int fieldNumber, final Object value) throws IOException { + if (value instanceof String) { + output.writeString(fieldNumber, (String) value); + } else { + output.writeBytes(fieldNumber, (ByteString) value); + } + } + + protected static void writeStringNoTag(CodedOutputStream output, final Object value) + throws IOException { + if (value instanceof String) { + output.writeStringNoTag((String) value); + } else { + output.writeBytesNoTag((ByteString) value); + } + } + + protected static void serializeIntegerMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + // Sorting the unboxed keys and then look up the values during serialization is 2x faster + // than sorting map entries with a custom comparator directly. + int[] keys = new int[m.size()]; + int index = 0; + for (int k : m.keySet()) { + keys[index++] = k; + } + Arrays.sort(keys); + for (int key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeLongMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + + long[] keys = new long[m.size()]; + int index = 0; + for (long k : m.keySet()) { + keys[index++] = k; + } + Arrays.sort(keys); + for (long key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeStringMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + + // Sorting the String keys and then look up the values during serialization is 25% faster than + // sorting map entries with a custom comparator directly. + String[] keys = new String[m.size()]; + keys = m.keySet().toArray(keys); + Arrays.sort(keys); + for (String key : keys) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + protected static void serializeBooleanMapTo( + CodedOutputStream out, + MapField field, + MapEntry defaultEntry, + int fieldNumber) + throws IOException { + Map m = field.getMap(); + if (!out.isSerializationDeterministic()) { + serializeMapTo(out, m, defaultEntry, fieldNumber); + return; + } + maybeSerializeBooleanEntryTo(out, m, defaultEntry, fieldNumber, false); + maybeSerializeBooleanEntryTo(out, m, defaultEntry, fieldNumber, true); + } + + private static void maybeSerializeBooleanEntryTo( + CodedOutputStream out, + Map m, + MapEntry defaultEntry, + int fieldNumber, + boolean key) + throws IOException { + if (m.containsKey(key)) { + out.writeMessage( + fieldNumber, defaultEntry.newBuilderForType().setKey(key).setValue(m.get(key)).build()); + } + } + + /** Serialize the map using the iteration order. */ + private static void serializeMapTo( + CodedOutputStream out, Map m, MapEntry defaultEntry, int fieldNumber) + throws IOException { + for (Map.Entry entry : m.entrySet()) { + out.writeMessage( + fieldNumber, + defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build()); + } + } +} diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Int32Value.java b/protobuf-api/src/main/java/com/google/protobuf/Int32Value.java similarity index 94% rename from protobuf-sdk/src/main/java/com/google/protobuf/Int32Value.java rename to protobuf-api/src/main/java/com/google/protobuf/Int32Value.java index e14fc28..3891573 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Int32Value.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Int32Value.java @@ -14,12 +14,12 @@ * Protobuf type {@code google.protobuf.Int32Value} */ public final class Int32Value extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Int32Value) Int32ValueOrBuilder { private static final long serialVersionUID = 0L; // Use Int32Value.newBuilder() to construct. - private Int32Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Int32Value(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Int32Value() { @@ -38,7 +38,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_Int32Value_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -159,20 +159,20 @@ public static com.google.protobuf.Int32Value parseFrom( } public static com.google.protobuf.Int32Value parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Int32Value parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Int32Value parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -180,20 +180,20 @@ public static com.google.protobuf.Int32Value parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Int32Value parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Int32Value parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -213,7 +213,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -227,7 +227,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Int32Value} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Int32Value) com.google.protobuf.Int32ValueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -236,7 +236,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_Int32Value_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -249,7 +249,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Int32ValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/Int32ValueOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/Int32ValueOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/Int32ValueOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Int64Value.java b/protobuf-api/src/main/java/com/google/protobuf/Int64Value.java similarity index 94% rename from protobuf-sdk/src/main/java/com/google/protobuf/Int64Value.java rename to protobuf-api/src/main/java/com/google/protobuf/Int64Value.java index 0d7c811..19b499c 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Int64Value.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Int64Value.java @@ -14,12 +14,12 @@ * Protobuf type {@code google.protobuf.Int64Value} */ public final class Int64Value extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Int64Value) Int64ValueOrBuilder { private static final long serialVersionUID = 0L; // Use Int64Value.newBuilder() to construct. - private Int64Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Int64Value(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Int64Value() { @@ -38,7 +38,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_Int64Value_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -160,20 +160,20 @@ public static com.google.protobuf.Int64Value parseFrom( } public static com.google.protobuf.Int64Value parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Int64Value parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Int64Value parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -181,20 +181,20 @@ public static com.google.protobuf.Int64Value parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Int64Value parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Int64Value parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -214,7 +214,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -228,7 +228,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Int64Value} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Int64Value) com.google.protobuf.Int64ValueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -237,7 +237,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_Int64Value_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -250,7 +250,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Int64ValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/Int64ValueOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/Int64ValueOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/Int64ValueOrBuilder.java diff --git a/protobuf-api/src/main/java/com/google/protobuf/Internal.java b/protobuf-api/src/main/java/com/google/protobuf/Internal.java index 3024aa9..52da3c2 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/Internal.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Internal.java @@ -14,7 +14,9 @@ import java.util.AbstractList; import java.util.AbstractMap; import java.util.AbstractSet; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -126,6 +128,67 @@ public static ByteBuffer copyByteBuffer(ByteBuffer source) { return result; } + /** + * Adds the {@code values} to the {@code list}. This is a helper method used by generated code. + * Users should ignore it. + * + * @throws NullPointerException if {@code values} or any of the elements of {@code values} is + * null. + */ + public static void addAll(final Iterable values, final List list) { + checkNotNull(values); + if (values instanceof LazyStringList) { + // For StringOrByteStringLists, check the underlying elements to avoid + // forcing conversions of ByteStrings to Strings. + // TODO: Could we just prohibit nulls in all protobuf lists and get rid of this? Is + // if even possible to hit this condition as all protobuf methods check for null first, + // right? + List lazyValues = ((LazyStringList) values).getUnderlyingElements(); + LazyStringList lazyList = (LazyStringList) list; + int begin = list.size(); + for (Object value : lazyValues) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (lazyList.size() - begin) + " is null."; + for (int i = lazyList.size() - 1; i >= begin; i--) { + lazyList.remove(i); + } + throw new NullPointerException(message); + } + if (value instanceof ByteString) { + lazyList.add((ByteString) value); + } else { + lazyList.add((String) value); + } + } + } else { + if (values instanceof PrimitiveNonBoxingCollection) { + list.addAll((Collection) values); + } else { + addAllCheckingNulls(values, list); + } + } + } + + // We check nulls as we iterate to avoid iterating over values twice. + private static void addAllCheckingNulls(Iterable values, List list) { + if (list instanceof ArrayList && values instanceof Collection) { + ((ArrayList) list).ensureCapacity(list.size() + ((Collection) values).size()); + } + int begin = list.size(); + for (T value : values) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (list.size() - begin) + " is null."; + for (int i = list.size() - 1; i >= begin; i--) { + list.remove(i); + } + throw new NullPointerException(message); + } + list.add(value); + } + } + /** * Helper called by generated code to determine if a byte array is a valid UTF-8 encoded string * such that the original bytes can be converted to a String object and then back to a byte array diff --git a/protobuf-api/src/main/java/com/google/protobuf/LazyField.java b/protobuf-api/src/main/java/com/google/protobuf/LazyField.java index d7dddd9..1ef780c 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/LazyField.java +++ b/protobuf-api/src/main/java/com/google/protobuf/LazyField.java @@ -20,7 +20,7 @@ * * @author xiangl@google.com (Xiang Li) */ -public class LazyField extends LazyFieldLite { +class LazyField extends LazyFieldLite { /** * Carry a message's default instance which is used by {@code hashCode()}, {@code equals()}, and diff --git a/protobuf-api/src/main/java/com/google/protobuf/LimitedInputStream.java b/protobuf-api/src/main/java/com/google/protobuf/LimitedInputStream.java new file mode 100644 index 0000000..f6eaad7 --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/LimitedInputStream.java @@ -0,0 +1,61 @@ +package com.google.protobuf; + +import java.io.FilterInputStream; +import java.io.IOException; +import java.io.InputStream; + +/** + * An InputStream implementations which reads from some other InputStream but is limited to a + * particular number of bytes. Used by mergeDelimitedFrom(). This is intentionally + * package-private so that UnknownFieldSet can share it. + */ +final class LimitedInputStream extends FilterInputStream { + private int limit; + + LimitedInputStream(InputStream in, int limit) { + super(in); + this.limit = limit; + } + + @Override + public int available() throws IOException { + return Math.min(super.available(), limit); + } + + @Override + public int read() throws IOException { + if (limit <= 0) { + return -1; + } + final int result = super.read(); + if (result >= 0) { + --limit; + } + return result; + } + + @Override + public int read(final byte[] b, final int off, int len) throws IOException { + if (limit <= 0) { + return -1; + } + len = Math.min(len, limit); + final int result = super.read(b, off, len); + if (result >= 0) { + limit -= result; + } + return result; + } + + @Override + public long skip(final long n) throws IOException { + // because we take the minimum of an int and a long, result is guaranteed to be + // less than or equal to Integer.MAX_INT so this cast is safe + int result = (int) super.skip(Math.min(n, limit)); + if (result >= 0) { + // if the superclass adheres to the contract for skip, this condition is always true + limit -= result; + } + return result; + } +} \ No newline at end of file diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/ListValue.java b/protobuf-api/src/main/java/com/google/protobuf/ListValue.java similarity index 94% rename from protobuf-sdk/src/main/java/com/google/protobuf/ListValue.java rename to protobuf-api/src/main/java/com/google/protobuf/ListValue.java index 8a2d1d8..e4e6496 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/ListValue.java +++ b/protobuf-api/src/main/java/com/google/protobuf/ListValue.java @@ -14,12 +14,12 @@ * Protobuf type {@code google.protobuf.ListValue} */ public final class ListValue extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.ListValue) ListValueOrBuilder { private static final long serialVersionUID = 0L; // Use ListValue.newBuilder() to construct. - private ListValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private ListValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private ListValue() { @@ -39,7 +39,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -208,20 +208,20 @@ public static com.google.protobuf.ListValue parseFrom( } public static com.google.protobuf.ListValue parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.ListValue parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.ListValue parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -229,20 +229,20 @@ public static com.google.protobuf.ListValue parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.ListValue parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.ListValue parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -262,7 +262,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -276,7 +276,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.ListValue} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.ListValue) com.google.protobuf.ListValueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -285,7 +285,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.StructProto.internal_static_google_protobuf_ListValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -298,7 +298,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } @@ -424,7 +424,7 @@ public Builder mergeFrom(com.google.protobuf.ListValue other) { values_ = other.values_; bitField0_ = (bitField0_ & ~0x00000001); valuesBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getValuesFieldBuilder() : null; } else { valuesBuilder_.addAllMessages(other.values_); @@ -496,8 +496,8 @@ private void ensureValuesIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Value, com.google.protobuf.Value.Builder, com.google.protobuf.ValueOrBuilder> valuesBuilder_; + private RepeatedFieldBuilderV3Internal< + Value, Value.Builder, ValueOrBuilder> valuesBuilder_; /** *

@@ -784,12 +784,12 @@ public com.google.protobuf.Value.Builder addValuesBuilder(
          getValuesBuilderList() {
       return getValuesFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Value, com.google.protobuf.Value.Builder, com.google.protobuf.ValueOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Value, Value.Builder, ValueOrBuilder>
         getValuesFieldBuilder() {
       if (valuesBuilder_ == null) {
-        valuesBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Value, com.google.protobuf.Value.Builder, com.google.protobuf.ValueOrBuilder>(
+        valuesBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Value, Value.Builder, ValueOrBuilder>(
                 values_,
                 ((bitField0_ & 0x00000001) != 0),
                 getParentForChildren(),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/ListValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/ListValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/ListValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/ListValueOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/MapEntry.java b/protobuf-api/src/main/java/com/google/protobuf/MapEntry.java
index c065bee..a8127c9 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/MapEntry.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/MapEntry.java
@@ -10,11 +10,23 @@
 import com.google.protobuf.Descriptors.Descriptor;
 import com.google.protobuf.Descriptors.EnumValueDescriptor;
 import com.google.protobuf.Descriptors.FieldDescriptor;
+
+import java.io.FilterInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import static com.google.protobuf.Internal.checkNotNull;
+
 /**
  * Implements MapEntry messages.
  *
@@ -24,7 +36,7 @@
  *
  * 

Protobuf internal. Users shouldn't use this class. */ -public final class MapEntry extends AbstractMessage { +public final class MapEntry implements Message { private static final class Metadata extends MapEntryLite.Metadata { @@ -216,8 +228,314 @@ public UnknownFieldSet getUnknownFields() { return UnknownFieldSet.getDefaultInstance(); } + protected int memoizedHashCode = 0; + + @Override + public ByteString toByteString() { + try { + final ByteString.CodedBuilder out = ByteString.newCodedBuilder(getSerializedSize()); + writeTo(out.getCodedOutput()); + return out.build(); + } catch (IOException e) { + throw new RuntimeException(getSerializingExceptionMessage("ByteString"), e); + } + } + + @Override + public byte[] toByteArray() { + try { + final byte[] result = new byte[getSerializedSize()]; + final CodedOutputStream output = CodedOutputStream.newInstance(result); + writeTo(output); + output.checkNoSpaceLeft(); + return result; + } catch (IOException e) { + throw new RuntimeException(getSerializingExceptionMessage("byte array"), e); + } + } + + @Override + public void writeTo(final OutputStream output) throws IOException { + final int bufferSize = CodedOutputStream.computePreferredBufferSize(getSerializedSize()); + final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize); + writeTo(codedOutput); + codedOutput.flush(); + } + + @Override + public void writeDelimitedTo(final OutputStream output) throws IOException { + final int serialized = getSerializedSize(); + final int bufferSize = + CodedOutputStream.computePreferredBufferSize( + CodedOutputStream.computeUInt32SizeNoTag(serialized) + serialized); + final CodedOutputStream codedOutput = CodedOutputStream.newInstance(output, bufferSize); + codedOutput.writeUInt32NoTag(serialized); + writeTo(codedOutput); + codedOutput.flush(); + } + + int getSerializedSize( + Schema schema) { + int memoizedSerializedSize = getMemoizedSerializedSize(); + if (memoizedSerializedSize == -1) { + memoizedSerializedSize = schema.getSerializedSize(this); + setMemoizedSerializedSize(memoizedSerializedSize); + } + return memoizedSerializedSize; + } + + private String getSerializingExceptionMessage(String target) { + return "Serializing " + + getClass().getName() + + " to a " + + target + + " threw an IOException (should never happen)."; + } + + protected static void checkByteStringIsUtf8(ByteString byteString) + throws IllegalArgumentException { + if (!byteString.isValidUtf8()) { + throw new IllegalArgumentException("Byte string is not UTF-8."); + } + } + + /** Interface for an enum which signifies which field in a {@code oneof} was specified. */ + protected interface InternalOneOfEnum { + /** + * Retrieves the field number of the field which was set in this {@code oneof}, or {@code 0} if + * none were. + */ + int getNumber(); + } + + /** + * Interface for the parent of a Builder that allows the builder to communicate invalidations back + * to the parent for use when using nested builders. + */ + protected interface BuilderParent { + + /** + * A builder becomes dirty whenever a field is modified -- including fields in nested builders + * -- and becomes clean when build() is called. Thus, when a builder becomes dirty, all its + * parents become dirty as well, and when it becomes clean, all its children become clean. The + * dirtiness state is used to invalidate certain cached values. + * + *

To this end, a builder calls markDirty() on its parent whenever it transitions from clean + * to dirty. The parent must propagate this call to its own parent, unless it was already dirty, + * in which case the grandparent must necessarily already be dirty as well. The parent can only + * transition back to "clean" after calling build() on all children. + */ + void markDirty(); + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public boolean hasOneof(Descriptors.OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + // TODO: Clear it when all subclasses have implemented this method. + @Override + public FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + @Override + public final String toString() { + return TextFormatInternal.printer().printToString(this); + } + + protected int memoizedSize = -1; + + int getMemoizedSerializedSize() { + return memoizedSize; + } + + void setMemoizedSerializedSize(int size) { + memoizedSize = size; + } + + @Override + public boolean equals(final Object other) { + if (other == this) { + return true; + } + if (!(other instanceof Message)) { + return false; + } + final Message otherMessage = (Message) other; + if (getDescriptorForType() != otherMessage.getDescriptorForType()) { + return false; + } + return compareFields(getAllFields(), otherMessage.getAllFields()) + && getUnknownFields().equals(otherMessage.getUnknownFields()); + } + + @Override + public int hashCode() { + int hash = memoizedHashCode; + if (hash == 0) { + hash = 41; + hash = (19 * hash) + getDescriptorForType().hashCode(); + hash = hashFields(hash, getAllFields()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + } + return hash; + } + + private static ByteString toByteString(Object value) { + if (value instanceof byte[]) { + return ByteString.copyFrom((byte[]) value); + } else { + return (ByteString) value; + } + } + + /** + * Compares two bytes fields. The parameters must be either a byte array or a ByteString object. + * They can be of different type though. + */ + private static boolean compareBytes(Object a, Object b) { + if (a instanceof byte[] && b instanceof byte[]) { + return Arrays.equals((byte[]) a, (byte[]) b); + } + return toByteString(a).equals(toByteString(b)); + } + + /** Converts a list of MapEntry messages into a Map used for equals() and hashCode(). */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static Map convertMapEntryListToMap(List list) { + if (list.isEmpty()) { + return Collections.emptyMap(); + } + Map result = new HashMap<>(); + Iterator iterator = list.iterator(); + Message entry = (Message) iterator.next(); + Descriptors.Descriptor descriptor = entry.getDescriptorForType(); + FieldDescriptor key = descriptor.findFieldByName("key"); + FieldDescriptor value = descriptor.findFieldByName("value"); + Object fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + while (iterator.hasNext()) { + entry = (Message) iterator.next(); + fieldValue = entry.getField(value); + if (fieldValue instanceof EnumValueDescriptor) { + fieldValue = ((EnumValueDescriptor) fieldValue).getNumber(); + } + result.put(entry.getField(key), fieldValue); + } + return result; + } + + /** Compares two map fields. The parameters must be a list of MapEntry messages. */ + @SuppressWarnings({"rawtypes", "unchecked"}) + private static boolean compareMapField(Object a, Object b) { + Map ma = convertMapEntryListToMap((List) a); + Map mb = convertMapEntryListToMap((List) b); + return MapFieldLite.equals(ma, mb); + } + + /** + * Compares two sets of fields. This method is used to implement {@link + * Message#equals(Object)} and {@link AbstractMutableMessage#equals(Object)}. It takes + * special care of bytes fields because immutable messages and mutable messages use different Java + * type to represent a bytes field and this method should be able to compare immutable messages, + * mutable messages and also an immutable message to a mutable message. + */ + static boolean compareFields(Map a, Map b) { + if (a.size() != b.size()) { + return false; + } + for (FieldDescriptor descriptor : a.keySet()) { + if (!b.containsKey(descriptor)) { + return false; + } + Object value1 = a.get(descriptor); + Object value2 = b.get(descriptor); + if (descriptor.getType() == FieldDescriptor.Type.BYTES) { + if (descriptor.isRepeated()) { + List list1 = (List) value1; + List list2 = (List) value2; + if (list1.size() != list2.size()) { + return false; + } + for (int i = 0; i < list1.size(); i++) { + if (!compareBytes(list1.get(i), list2.get(i))) { + return false; + } + } + } else { + // Compares a singular bytes field. + if (!compareBytes(value1, value2)) { + return false; + } + } + } else if (descriptor.isMapField()) { + if (!compareMapField(value1, value2)) { + return false; + } + } else { + // Compare non-bytes fields. + if (!value1.equals(value2)) { + return false; + } + } + } + return true; + } + + /** Calculates the hash code of a map field. {@code value} must be a list of MapEntry messages. */ + @SuppressWarnings("unchecked") + private static int hashMapField(Object value) { + return MapFieldLite.calculateHashCodeForMap(convertMapEntryListToMap((List) value)); + } + + /** Get a hash code for given fields and values, using the given seed. */ + @SuppressWarnings("unchecked") + protected static int hashFields(int hash, Map map) { + for (Map.Entry entry : map.entrySet()) { + FieldDescriptor field = entry.getKey(); + Object value = entry.getValue(); + hash = (37 * hash) + field.getNumber(); + if (field.isMapField()) { + hash = (53 * hash) + hashMapField(value); + } else if (field.getType() != FieldDescriptor.Type.ENUM) { + hash = (53 * hash) + value.hashCode(); + } else if (field.isRepeated()) { + List list = (List) value; + hash = (53 * hash) + Internal.hashEnumList(list); + } else { + hash = (53 * hash) + Internal.hashEnum((Internal.EnumLite) value); + } + } + return hash; + } + + /** + * Package private helper method for AbstractParser to create UninitializedMessageException with + * missing field information. + */ + UninitializedMessageException newUninitializedMessageException() { + return Builder.newUninitializedMessageException(this); + } + + /** Builder to create {@link MapEntry} messages. */ - public static class Builder extends AbstractMessage.Builder> { + public static class Builder implements Message.Builder { private final Metadata metadata; private K key; private V value; @@ -417,10 +735,387 @@ public UnknownFieldSet getUnknownFields() { return UnknownFieldSet.getDefaultInstance(); } - @Override public Builder clone() { return new Builder<>(metadata, key, value, hasKey, hasValue); } + + @Override + public boolean mergeDelimitedFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final int firstByte = input.read(); + if (firstByte == -1) { + return false; + } + final int size = CodedInputStream.readRawVarint32(firstByte, input); + final InputStream limitedInput = new LimitedInputStream(input, size); + mergeFrom(limitedInput, extensionRegistry); + return true; + } + + @Override + public boolean mergeDelimitedFrom(final InputStream input) throws IOException { + return mergeDelimitedFrom(input, ExtensionRegistryLite.getEmptyRegistry()); + } + + @Override + @SuppressWarnings("unchecked") // isInstance takes care of this + public MapEntry.Builder mergeFrom(final MessageLite other) { + if (!getDefaultInstanceForType().getClass().isInstance(other)) { + throw new IllegalArgumentException( + "mergeFrom(MessageLite) can only merge messages of the same type."); + } + + return internalMergeFrom(other); + } + + private String getReadingExceptionMessage(String target) { + return "Reading " + + getClass().getName() + + " from a " + + target + + " threw an IOException (should never happen)."; + } + + // We check nulls as we iterate to avoid iterating over values twice. + private static void addAllCheckingNulls(Iterable values, List list) { + if (list instanceof ArrayList && values instanceof Collection) { + ((ArrayList) list).ensureCapacity(list.size() + ((Collection) values).size()); + } + int begin = list.size(); + for (T value : values) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (list.size() - begin) + " is null."; + for (int i = list.size() - 1; i >= begin; i--) { + list.remove(i); + } + throw new NullPointerException(message); + } + list.add(value); + } + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + MessageLite message) { + return new UninitializedMessageException(message); + } + + // For binary compatibility. + @Deprecated + protected static void addAll(final Iterable values, final Collection list) { + addAll(values, (List) list); + } + + /** + * Adds the {@code values} to the {@code list}. This is a helper method used by generated code. + * Users should ignore it. + * + * @throws NullPointerException if {@code values} or any of the elements of {@code values} is + * null. + */ + protected static void addAll(final Iterable values, final List list) { + checkNotNull(values); + if (values instanceof LazyStringList) { + // For StringOrByteStringLists, check the underlying elements to avoid + // forcing conversions of ByteStrings to Strings. + // TODO: Could we just prohibit nulls in all protobuf lists and get rid of this? Is + // if even possible to hit this condition as all protobuf methods check for null first, + // right? + List lazyValues = ((LazyStringList) values).getUnderlyingElements(); + LazyStringList lazyList = (LazyStringList) list; + int begin = list.size(); + for (Object value : lazyValues) { + if (value == null) { + // encountered a null value so we must undo our modifications prior to throwing + String message = "Element at index " + (lazyList.size() - begin) + " is null."; + for (int i = lazyList.size() - 1; i >= begin; i--) { + lazyList.remove(i); + } + throw new NullPointerException(message); + } + if (value instanceof ByteString) { + lazyList.add((ByteString) value); + } else { + lazyList.add((String) value); + } + } + } else { + if (values instanceof PrimitiveNonBoxingCollection) { + list.addAll((Collection) values); + } else { + addAllCheckingNulls(values, list); + } + } + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public boolean hasOneof(Descriptors.OneofDescriptor oneof) { + throw new UnsupportedOperationException("hasOneof() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public FieldDescriptor getOneofFieldDescriptor(Descriptors.OneofDescriptor oneof) { + throw new UnsupportedOperationException("getOneofFieldDescriptor() is not implemented."); + } + + /** TODO: Clear it when all subclasses have implemented this method. */ + @Override + public MapEntry.Builder clearOneof(Descriptors.OneofDescriptor oneof) { + throw new UnsupportedOperationException("clearOneof() is not implemented."); + } + + @Override + public MapEntry.Builder clear() { + for (final Map.Entry entry : getAllFields().entrySet()) { + clearField(entry.getKey()); + } + return (MapEntry.Builder) this; + } + + @Override + public List findInitializationErrors() { + return MessageReflection.findMissingFields(this); + } + + @Override + public String getInitializationErrorString() { + return MessageReflection.delimitWithCommas(findInitializationErrors()); + } + + protected MapEntry.Builder internalMergeFrom(MessageLite other) { + return mergeFrom((Message) other); + } + + @Override + public MapEntry.Builder mergeFrom(final Message other) { + return mergeFrom(other, other.getAllFields()); + } + + MapEntry.Builder mergeFrom(final Message other, Map allFields) { + if (other.getDescriptorForType() != getDescriptorForType()) { + throw new IllegalArgumentException( + "mergeFrom(Message) can only merge messages of the same type."); + } + + // Note: We don't attempt to verify that other's fields have valid + // types. Doing so would be a losing battle. We'd have to verify + // all sub-messages as well, and we'd have to make copies of all of + // them to insure that they don't change after verification (since + // the Message interface itself cannot enforce immutability of + // implementations). + + for (final Map.Entry entry : allFields.entrySet()) { + final FieldDescriptor field = entry.getKey(); + if (field.isRepeated()) { + for (final Object element : (List) entry.getValue()) { + addRepeatedField(field, element); + } + } else if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { + final Message existingValue = (Message) getField(field); + if (existingValue == existingValue.getDefaultInstanceForType()) { + setField(field, entry.getValue()); + } else { + setField( + field, + existingValue + .newBuilderForType() + .mergeFrom(existingValue) + .mergeFrom((Message) entry.getValue()) + .build()); + } + } else { + setField(field, entry.getValue()); + } + } + + mergeUnknownFields(other.getUnknownFields()); + + return (MapEntry.Builder) this; + } + + @Override + public MapEntry.Builder mergeFrom(final CodedInputStream input) throws IOException { + return mergeFrom(input, ExtensionRegistry.getEmptyRegistry()); + } + + @Override + public MapEntry.Builder mergeFrom( + final CodedInputStream input, final ExtensionRegistryLite extensionRegistry) + throws IOException { + boolean discardUnknown = input.shouldDiscardUnknownFields(); + final UnknownFieldSet.Builder unknownFields = + discardUnknown ? null : getUnknownFieldSetBuilder(); + MessageReflection.mergeMessageFrom(this, unknownFields, input, extensionRegistry); + if (unknownFields != null) { + setUnknownFieldSetBuilder(unknownFields); + } + return (MapEntry.Builder) this; + } + + protected UnknownFieldSet.Builder getUnknownFieldSetBuilder() { + return UnknownFieldSet.newBuilder(getUnknownFields()); + } + + protected void setUnknownFieldSetBuilder(final UnknownFieldSet.Builder builder) { + setUnknownFields(builder.build()); + } + + @Override + public MapEntry.Builder mergeUnknownFields(final UnknownFieldSet unknownFields) { + setUnknownFields( + UnknownFieldSet.newBuilder(getUnknownFields()).mergeFrom(unknownFields).build()); + return (MapEntry.Builder) this; + } + + @Override + public MapEntry.Builder getFieldBuilder(final FieldDescriptor field) { + throw new UnsupportedOperationException( + "getFieldBuilder() called on an unsupported message type."); + } + + @Override + public MapEntry.Builder getRepeatedFieldBuilder(final FieldDescriptor field, int index) { + throw new UnsupportedOperationException( + "getRepeatedFieldBuilder() called on an unsupported message type."); + } + + @Override + public String toString() { + return TextFormatInternal.printer().printToString(this); + } + + /** Construct an UninitializedMessageException reporting missing fields in the given message. */ + protected static UninitializedMessageException newUninitializedMessageException( + Message message) { + return new UninitializedMessageException(MessageReflection.findMissingFields(message)); + } + + public MapEntry.Builder mergeFrom(final ByteString data) throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input); + input.checkLastTagWas(0); + return (MapEntry.Builder) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public MapEntry.Builder mergeFrom( + final ByteString data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = data.newCodedInput(); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (MapEntry.Builder) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("ByteString"), e); + } + } + + public MapEntry.Builder mergeFrom(final byte[] data) throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length); + } + + public MapEntry.Builder mergeFrom(final byte[] data, final int off, final int len) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input); + input.checkLastTagWas(0); + return (MapEntry.Builder) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public MapEntry.Builder mergeFrom(final byte[] data, final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + return mergeFrom(data, 0, data.length, extensionRegistry); + } + + public MapEntry.Builder mergeFrom( + final byte[] data, + final int off, + final int len, + final ExtensionRegistryLite extensionRegistry) + throws InvalidProtocolBufferException { + try { + final CodedInputStream input = CodedInputStream.newInstance(data, off, len); + mergeFrom(input, extensionRegistry); + input.checkLastTagWas(0); + return (MapEntry.Builder) this; + } catch (InvalidProtocolBufferException e) { + throw e; + } catch (IOException e) { + throw new RuntimeException(getReadingExceptionMessage("byte array"), e); + } + } + + public MapEntry.Builder mergeFrom(final InputStream input) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput); + codedInput.checkLastTagWas(0); + return (MapEntry.Builder) this; + } + + public MapEntry.Builder mergeFrom( + final InputStream input, final ExtensionRegistryLite extensionRegistry) throws IOException { + final CodedInputStream codedInput = CodedInputStream.newInstance(input); + mergeFrom(codedInput, extensionRegistry); + codedInput.checkLastTagWas(0); + return (MapEntry.Builder) this; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashLong(long n) { + return (int) (n ^ (n >>> 32)); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashBoolean(boolean b) { + return b ? 1231 : 1237; + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnum(Internal.EnumLite e) { + return e.getNumber(); + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 + * generated code. + */ + @Deprecated + protected static int hashEnumList(List list) { + int hash = 1; + for (Internal.EnumLite e : list) { + hash = 31 * hash + hashEnum(e); + } + return hash; + } } private static boolean isInitialized(Metadata metadata, V value) { diff --git a/protobuf-api/src/main/java/com/google/protobuf/MapEntryLite.java b/protobuf-api/src/main/java/com/google/protobuf/MapEntryLite.java index 99f3460..61b1f65 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/MapEntryLite.java +++ b/protobuf-api/src/main/java/com/google/protobuf/MapEntryLite.java @@ -19,7 +19,7 @@ * *

Protobuf internal. Users shouldn't use. */ -public class MapEntryLite { +class MapEntryLite { static class Metadata { public final WireFormat.FieldType keyType; diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/MapFieldBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/MapFieldBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/MapFieldBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/MapFieldBuilder.java diff --git a/protobuf-api/src/main/java/com/google/protobuf/MapFieldLite.java b/protobuf-api/src/main/java/com/google/protobuf/MapFieldLite.java index bc5704b..a94825c 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/MapFieldLite.java +++ b/protobuf-api/src/main/java/com/google/protobuf/MapFieldLite.java @@ -21,7 +21,7 @@ * *

This class is a protobuf implementation detail. Users shouldn't use this class directly. */ -public final class MapFieldLite extends LinkedHashMap { +final class MapFieldLite extends LinkedHashMap { private boolean isMutable; diff --git a/protobuf-api/src/main/java/com/google/protobuf/Message.java b/protobuf-api/src/main/java/com/google/protobuf/Message.java index 5b02c46..830587e 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/Message.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Message.java @@ -24,6 +24,26 @@ @CheckReturnValue public interface Message extends MessageLite, MessageOrBuilder { + /** + * Interface for the parent of a Builder that allows the builder to communicate invalidations back + * to the parent for use when using nested builders. + */ + interface BuilderParent { + + /** + * A builder becomes dirty whenever a field is modified -- including fields in nested builders + * -- and becomes clean when build() is called. Thus, when a builder becomes dirty, all its + * parents become dirty as well, and when it becomes clean, all its children become clean. The + * dirtiness state is used to invalidate certain cached values. + * + *

To this end, a builder calls markDirty() on its parent whenever it transitions from clean + * to dirty. The parent must propagate this call to its own parent, unless it was already dirty, + * in which case the grandparent must necessarily already be dirty as well. The parent can only + * transition back to "clean" after calling build() on all children. + */ + void markDirty(); + } + // (From MessageLite, re-declared here only for return type covariance.) @Override Parser getParserForType(); @@ -64,6 +84,10 @@ public interface Message extends MessageLite, MessageOrBuilder { @Override String toString(); + default boolean isGenerated() { + return false; + } + // ================================================================= // Builders @@ -71,11 +95,39 @@ public interface Message extends MessageLite, MessageOrBuilder { @Override Builder newBuilderForType(); + default Message.Builder newBuilderForType(BuilderParent parent) { + throw new UnsupportedOperationException("Nested builder is not supported for this type."); + } + @Override Builder toBuilder(); /** Abstract interface implemented by Protocol Message builders. */ interface Builder extends MessageLite.Builder, MessageOrBuilder { + + /** + * Used to support nested builders and called to mark this builder as clean. Clean builders will + * propagate the {@link BuilderParent#markDirty()} event to their parent builders, while dirty + * builders will not, as their parents should be dirty already. + * + *

NOTE: Implementations that don't support nested builders don't need to override this + * method. + */ + default void markClean() { + throw new IllegalStateException("Should be overridden by subclasses."); + } + + /** + * Used to support nested builders and called when this nested builder is no longer used by its + * parent builder and should release the reference to its parent builder. + * + *

NOTE: Implementations that don't support nested builders don't need to override this + * method. + */ + default void dispose() { + throw new IllegalStateException("Should be overridden by subclasses."); + } + // (From MessageLite.Builder, re-declared here only for return type // covariance.) @Override @@ -263,5 +315,9 @@ Builder mergeFrom(InputStream input, ExtensionRegistryLite extensionRegistry) @Override boolean mergeDelimitedFrom(InputStream input, ExtensionRegistryLite extensionRegistry) throws IOException; + + default boolean isGenerated() { + return false; + } } } diff --git a/protobuf-api/src/main/java/com/google/protobuf/MessageReflection.java b/protobuf-api/src/main/java/com/google/protobuf/MessageReflection.java index e33cc45..7dad81d 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/MessageReflection.java +++ b/protobuf-api/src/main/java/com/google/protobuf/MessageReflection.java @@ -638,7 +638,7 @@ public WireFormat.Utf8Validation getUtf8Validation(Descriptors.FieldDescriptor d return WireFormat.Utf8Validation.STRICT; } // TODO: support lazy strings for repeated fields. - if (!descriptor.isRepeated() && builder instanceof GeneratedMessage.Builder) { + if (!descriptor.isRepeated() && builder.isGenerated()) { return WireFormat.Utf8Validation.LAZY; } return WireFormat.Utf8Validation.LOOSE; diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Method.java b/protobuf-api/src/main/java/com/google/protobuf/Method.java similarity index 95% rename from protobuf-sdk/src/main/java/com/google/protobuf/Method.java rename to protobuf-api/src/main/java/com/google/protobuf/Method.java index 541f0f1..f38d63b 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Method.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Method.java @@ -12,12 +12,12 @@ * Protobuf type {@code google.protobuf.Method} */ public final class Method extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Method) MethodOrBuilder { private static final long serialVersionUID = 0L; // Use Method.newBuilder() to construct. - private Method(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Method(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Method() { @@ -41,7 +41,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.ApiProto.internal_static_google_protobuf_Method_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -320,17 +320,17 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(requestTypeUrl_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, requestTypeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(requestTypeUrl_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, requestTypeUrl_); } if (requestStreaming_ != false) { output.writeBool(3, requestStreaming_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(responseTypeUrl_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, responseTypeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(responseTypeUrl_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 4, responseTypeUrl_); } if (responseStreaming_ != false) { output.writeBool(5, responseStreaming_); @@ -350,18 +350,18 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(requestTypeUrl_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, requestTypeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(requestTypeUrl_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, requestTypeUrl_); } if (requestStreaming_ != false) { size += com.google.protobuf.CodedOutputStream .computeBoolSize(3, requestStreaming_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(responseTypeUrl_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, responseTypeUrl_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(responseTypeUrl_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(4, responseTypeUrl_); } if (responseStreaming_ != false) { size += com.google.protobuf.CodedOutputStream @@ -471,20 +471,20 @@ public static com.google.protobuf.Method parseFrom( } public static com.google.protobuf.Method parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Method parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Method parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -492,20 +492,20 @@ public static com.google.protobuf.Method parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Method parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Method parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -525,7 +525,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -537,7 +537,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Method} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Method) com.google.protobuf.MethodOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -546,7 +546,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.ApiProto.internal_static_google_protobuf_Method_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -559,7 +559,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } @@ -730,7 +730,7 @@ public Builder mergeFrom(com.google.protobuf.Method other) { options_ = other.options_; bitField0_ = (bitField0_ & ~0x00000020); optionsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getOptionsFieldBuilder() : null; } else { optionsBuilder_.addAllMessages(other.options_); @@ -1199,8 +1199,8 @@ private void ensureOptionsIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_; + private RepeatedFieldBuilderV3Internal< + Option, Option.Builder, OptionOrBuilder> optionsBuilder_; /** *

@@ -1487,12 +1487,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000020) != 0),
                 getParentForChildren(),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/MethodOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/MethodOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/MethodOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/MethodOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Mixin.java b/protobuf-api/src/main/java/com/google/protobuf/Mixin.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Mixin.java
rename to protobuf-api/src/main/java/com/google/protobuf/Mixin.java
index 56f92d0..b73f95d 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Mixin.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Mixin.java
@@ -89,12 +89,12 @@
  * Protobuf type {@code google.protobuf.Mixin}
  */
 public final class Mixin extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Mixin)
     MixinOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Mixin.newBuilder() to construct.
-  private Mixin(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Mixin(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Mixin() {
@@ -115,7 +115,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.ApiProto.internal_static_google_protobuf_Mixin_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -232,11 +232,11 @@ public final boolean isInitialized() {
   @java.lang.Override
   public void writeTo(com.google.protobuf.CodedOutputStream output)
                       throws java.io.IOException {
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(root_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 2, root_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(root_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 2, root_);
     }
     getUnknownFields().writeTo(output);
   }
@@ -247,11 +247,11 @@ public int getSerializedSize() {
     if (size != -1) return size;
 
     size = 0;
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
     }
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(root_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, root_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(root_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(2, root_);
     }
     size += getUnknownFields().getSerializedSize();
     memoizedSize = size;
@@ -326,20 +326,20 @@ public static com.google.protobuf.Mixin parseFrom(
   }
   public static com.google.protobuf.Mixin parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Mixin parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Mixin parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -347,20 +347,20 @@ public static com.google.protobuf.Mixin parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Mixin parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Mixin parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -380,7 +380,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -469,7 +469,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Mixin}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Mixin)
       com.google.protobuf.MixinOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -478,7 +478,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.ApiProto.internal_static_google_protobuf_Mixin_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -491,7 +491,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/MixinOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/MixinOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/MixinOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/MixinOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/NullValue.java b/protobuf-api/src/main/java/com/google/protobuf/NullValue.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/NullValue.java
rename to protobuf-api/src/main/java/com/google/protobuf/NullValue.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Option.java b/protobuf-api/src/main/java/com/google/protobuf/Option.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Option.java
rename to protobuf-api/src/main/java/com/google/protobuf/Option.java
index 119fbaf..331d8aa 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Option.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Option.java
@@ -13,12 +13,12 @@
  * Protobuf type {@code google.protobuf.Option}
  */
 public final class Option extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Option)
     OptionOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Option.newBuilder() to construct.
-  private Option(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Option(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Option() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.TypeProto.internal_static_google_protobuf_Option_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -160,8 +160,8 @@ public final boolean isInitialized() {
   @java.lang.Override
   public void writeTo(com.google.protobuf.CodedOutputStream output)
                       throws java.io.IOException {
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_);
     }
     if (((bitField0_ & 0x00000001) != 0)) {
       output.writeMessage(2, getValue());
@@ -175,8 +175,8 @@ public int getSerializedSize() {
     if (size != -1) return size;
 
     size = 0;
-    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
+    if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) {
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_);
     }
     if (((bitField0_ & 0x00000001) != 0)) {
       size += com.google.protobuf.CodedOutputStream
@@ -260,20 +260,20 @@ public static com.google.protobuf.Option parseFrom(
   }
   public static com.google.protobuf.Option parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Option parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Option parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -281,20 +281,20 @@ public static com.google.protobuf.Option parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Option parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Option parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -314,7 +314,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -327,7 +327,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Option}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Option)
       com.google.protobuf.OptionOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -336,7 +336,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.TypeProto.internal_static_google_protobuf_Option_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -349,12 +349,12 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
       maybeForceBuilderInitialization();
     }
     private void maybeForceBuilderInitialization() {
-      if (com.google.protobuf.GeneratedMessageV3
+      if (com.google.protobuf.GeneratedMessageV3Internal
               .alwaysUseFieldBuilders) {
         getValueFieldBuilder();
       }
@@ -630,8 +630,8 @@ public Builder setNameBytes(
     }
 
     private com.google.protobuf.Any value_;
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> valueBuilder_;
+    private SingleFieldBuilderV3Internal<
+            Any, Any.Builder, AnyOrBuilder> valueBuilder_;
     /**
      * 
      * The option's value packed in an Any message. If the value is a primitive,
@@ -799,12 +799,12 @@ public com.google.protobuf.AnyOrBuilder getValueOrBuilder() {
      *
      * .google.protobuf.Any value = 2;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            Any, Any.Builder, AnyOrBuilder>
         getValueFieldBuilder() {
       if (valueBuilder_ == null) {
-        valueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.Any, com.google.protobuf.Any.Builder, com.google.protobuf.AnyOrBuilder>(
+        valueBuilder_ = new SingleFieldBuilderV3Internal<
+                    Any, Any.Builder, AnyOrBuilder>(
                 getValue(),
                 getParentForChildren(),
                 isClean());
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/OptionOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/OptionOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/OptionOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/OptionOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3Internal.java b/protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3Internal.java
new file mode 100644
index 0000000..016085a
--- /dev/null
+++ b/protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3Internal.java
@@ -0,0 +1,647 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
+
+package com.google.protobuf;
+
+import static com.google.protobuf.Internal.checkNotNull;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.RandomAccess;
+
+/**
+ * {@code RepeatedFieldBuilderV3} implements a structure that a protocol message uses to hold a
+ * repeated field of other protocol messages. It supports the classical use case of adding immutable
+ * {@link Message}'s to the repeated field and is highly optimized around this (no extra memory
+ * allocations and sharing of immutable arrays). 
+ * It also supports the additional use case of adding a {@link Message.Builder} to the repeated + * field and deferring conversion of that {@code Builder} to an immutable {@code Message}. In this + * way, it's possible to maintain a tree of {@code Builder}'s that acts as a fully read/write data + * structure.
+ * Logically, one can think of a tree of builders as converting the entire tree to messages when + * build is called on the root or when any method is called that desires a Message instead of a + * Builder. In terms of the implementation, the {@code SingleFieldBuilderV3} and {@code + * RepeatedFieldBuilderV3} classes cache messages that were created so that messages only need to be + * created when some change occurred in its builder or a builder for one of its descendants. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + * @author jonp@google.com (Jon Perlow) + */ +class RepeatedFieldBuilderV3Internal< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + implements Message.BuilderParent { + + // Parent to send changes to. + private Message.BuilderParent parent; + + // List of messages. Never null. It may be immutable, in which case + // isMessagesListMutable will be false. See note below. + private List messages; + + // Whether messages is an mutable array that can be modified. + private boolean isMessagesListMutable; + + // List of builders. May be null, in which case, no nested builders were + // created. If not null, entries represent the builder for that index. + private List> builders; + + // Here are the invariants for messages and builders: + // 1. messages is never null and its count corresponds to the number of items + // in the repeated field. + // 2. If builders is non-null, messages and builders MUST always + // contain the same number of items. + // 3. Entries in either array can be null, but for any index, there MUST be + // either a Message in messages or a builder in builders. + // 4. If the builder at an index is non-null, the builder is + // authoritative. This is the case where a Builder was set on the index. + // Any message in the messages array MUST be ignored. + // t. If the builder at an index is null, the message in the messages + // list is authoritative. This is the case where a Message (not a Builder) + // was set directly for an index. + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + private boolean isClean; + + // A view of this builder that exposes a List interface of messages. This is + // initialized on demand. This is fully backed by this object and all changes + // are reflected in it. Access to any item converts it to a message if it + // was a builder. + private MessageExternalList externalMessageList; + + // A view of this builder that exposes a List interface of builders. This is + // initialized on demand. This is fully backed by this object and all changes + // are reflected in it. Access to any item converts it to a builder if it + // was a message. + private BuilderExternalList externalBuilderList; + + // A view of this builder that exposes a List interface of the interface + // implemented by messages and builders. This is initialized on demand. This + // is fully backed by this object and all changes are reflected in it. + // Access to any item returns either a builder or message depending on + // what is most efficient. + private MessageOrBuilderExternalList externalMessageOrBuilderList; + + /** + * Constructs a new builder with an empty list of messages. + * + * @param messages the current list of messages + * @param isMessagesListMutable Whether the messages list is mutable + * @param parent a listener to notify of changes + * @param isClean whether the builder is initially marked clean + */ + public RepeatedFieldBuilderV3Internal( + List messages, + boolean isMessagesListMutable, + Message.BuilderParent parent, + boolean isClean) { + this.messages = messages; + this.isMessagesListMutable = isMessagesListMutable; + this.parent = parent; + this.isClean = isClean; + } + + public void dispose() { + // Null out parent so we stop sending it invalidations. + parent = null; + } + + /** + * Ensures that the list of messages is mutable so it can be updated. If it's immutable, a copy is + * made. + */ + private void ensureMutableMessageList() { + if (!isMessagesListMutable) { + messages = new ArrayList(messages); + isMessagesListMutable = true; + } + } + + /** + * Ensures that the list of builders is not null. If it's null, the list is created and + * initialized to be the same size as the messages list with null entries. + */ + private void ensureBuilders() { + if (this.builders == null) { + this.builders = new ArrayList>(messages.size()); + for (int i = 0; i < messages.size(); i++) { + builders.add(null); + } + } + } + + /** + * Gets the count of items in the list. + * + * @return the count of items in the list. + */ + public int getCount() { + return messages.size(); + } + + /** + * Gets whether the list is empty. + * + * @return whether the list is empty + */ + public boolean isEmpty() { + return messages.isEmpty(); + } + + /** + * Get the message at the specified index. If the message is currently stored as a {@code + * Builder}, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} + * on it. + * + * @param index the index of the message to get + * @return the message for the specified index + */ + public MType getMessage(int index) { + return getMessage(index, false); + } + + /** + * Get the message at the specified index. If the message is currently stored as a {@code + * Builder}, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} + * on it. + * + * @param index the index of the message to get + * @param forBuild this is being called for build so we want to make sure we + * SingleFieldBuilderV3.build to send dirty invalidations + * @return the message for the specified index + */ + private MType getMessage(int index, boolean forBuild) { + if (this.builders == null) { + // We don't have any builders -- return the current Message. + // This is the case where no builder was created, so we MUST have a + // Message. + return messages.get(index); + } + + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + // We don't have a builder -- return the current message. + // This is the case where no builder was created for the entry at index, + // so we MUST have a message. + return messages.get(index); + + } else { + return forBuild ? builder.build() : builder.getMessage(); + } + } + + /** + * Gets a builder for the specified index. If no builder has been created for that index, a + * builder is created on demand by calling {@link Message#toBuilder}. + * + * @param index the index of the message to get + * @return The builder for that index + */ + public BType getBuilder(int index) { + ensureBuilders(); + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + MType message = messages.get(index); + builder = new SingleFieldBuilderV3Internal(message, this, isClean); + builders.set(index, builder); + } + return builder.getBuilder(); + } + + /** + * Gets the base class interface for the specified index. This may either be a builder or a + * message. It will return whatever is more efficient. + * + * @param index the index of the message to get + * @return the message or builder for the index as the base class interface + */ + @SuppressWarnings("unchecked") + public IType getMessageOrBuilder(int index) { + if (this.builders == null) { + // We don't have any builders -- return the current Message. + // This is the case where no builder was created, so we MUST have a + // Message. + return (IType) messages.get(index); + } + + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + // We don't have a builder -- return the current message. + // This is the case where no builder was created for the entry at index, + // so we MUST have a message. + return (IType) messages.get(index); + + } else { + return builder.getMessageOrBuilder(); + } + } + + /** + * Sets a message at the specified index replacing the existing item at that index. + * + * @param index the index to set. + * @param message the message to set + * @return the builder + */ + @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal setMessage(int index, MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.set(index, message); + if (builders != null) { + SingleFieldBuilderV3Internal entry = builders.set(index, null); + if (entry != null) { + entry.dispose(); + } + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends the specified element to the end of this list. + * + * @param message the message to add + * @return the builder + */ + @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addMessage(MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.add(message); + if (builders != null) { + builders.add(null); + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Inserts the specified message at the specified position in this list. Shifts the element + * currently at that position (if any) and any subsequent elements to the right (adds one to their + * indices). + * + * @param index the index at which to insert the message + * @param message the message to add + * @return the builder + */ + @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addMessage(int index, MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.add(index, message); + if (builders != null) { + builders.add(index, null); + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends all of the messages in the specified collection to the end of this list, in the order + * that they are returned by the specified collection's iterator. + * + * @param values the messages to add + * @return the builder + */ + @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addAllMessages( + Iterable values) { + for (final MType value : values) { + checkNotNull(value); + } + + // If we can inspect the size, we can more efficiently add messages. + int size = -1; + if (values instanceof Collection) { + final Collection collection = (Collection) values; + if (collection.isEmpty()) { + return this; + } + size = collection.size(); + } + ensureMutableMessageList(); + + if (size >= 0 && messages instanceof ArrayList) { + ((ArrayList) messages).ensureCapacity(messages.size() + size); + } + + for (MType value : values) { + addMessage(value); + } + + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends a new builder to the end of this list and returns the builder. + * + * @param message the message to add which is the basis of the builder + * @return the new builder + */ + public BType addBuilder(MType message) { + ensureMutableMessageList(); + ensureBuilders(); + SingleFieldBuilderV3Internal builder = + new SingleFieldBuilderV3Internal(message, this, isClean); + messages.add(null); + builders.add(builder); + onChanged(); + incrementModCounts(); + return builder.getBuilder(); + } + + /** + * Inserts a new builder at the specified position in this list. Shifts the element currently at + * that position (if any) and any subsequent elements to the right (adds one to their indices). + * + * @param index the index at which to insert the builder + * @param message the message to add which is the basis of the builder + * @return the builder + */ + public BType addBuilder(int index, MType message) { + ensureMutableMessageList(); + ensureBuilders(); + SingleFieldBuilderV3Internal builder = + new SingleFieldBuilderV3Internal(message, this, isClean); + messages.add(index, null); + builders.add(index, builder); + onChanged(); + incrementModCounts(); + return builder.getBuilder(); + } + + /** + * Removes the element at the specified position in this list. Shifts any subsequent elements to + * the left (subtracts one from their indices). + * + * @param index the index at which to remove the message + */ + public void remove(int index) { + ensureMutableMessageList(); + messages.remove(index); + if (builders != null) { + SingleFieldBuilderV3Internal entry = builders.remove(index); + if (entry != null) { + entry.dispose(); + } + } + onChanged(); + incrementModCounts(); + } + + /** Removes all of the elements from this list. The list will be empty after this call returns. */ + public void clear() { + messages = Collections.emptyList(); + isMessagesListMutable = false; + if (builders != null) { + for (SingleFieldBuilderV3Internal entry : builders) { + if (entry != null) { + entry.dispose(); + } + } + builders = null; + } + onChanged(); + incrementModCounts(); + } + + /** + * Builds the list of messages from the builder and returns them. + * + * @return an immutable list of messages + */ + public List build() { + // Now that build has been called, we are required to dispatch + // invalidations. + isClean = true; + + if (!isMessagesListMutable && builders == null) { + // We still have an immutable list and we never created a builder. + return messages; + } + + boolean allMessagesInSync = true; + if (!isMessagesListMutable) { + // We still have an immutable list. Let's see if any of them are out + // of sync with their builders. + for (int i = 0; i < messages.size(); i++) { + Message message = messages.get(i); + SingleFieldBuilderV3Internal builder = builders.get(i); + if (builder != null) { + if (builder.build() != message) { + allMessagesInSync = false; + break; + } + } + } + if (allMessagesInSync) { + // Immutable list is still in sync. + return messages; + } + } + + // Need to make sure messages is up to date + ensureMutableMessageList(); + for (int i = 0; i < messages.size(); i++) { + messages.set(i, getMessage(i, true)); + } + + // We're going to return our list as immutable so we mark that we can + // no longer update it. + messages = Collections.unmodifiableList(messages); + isMessagesListMutable = false; + return messages; + } + + /** + * Gets a view of the builder as a list of messages. The returned list is live and will reflect + * any changes to the underlying builder. + * + * @return the messages in the list + */ + public List getMessageList() { + if (externalMessageList == null) { + externalMessageList = new MessageExternalList(this); + } + return externalMessageList; + } + + /** + * Gets a view of the builder as a list of builders. This returned list is live and will reflect + * any changes to the underlying builder. + * + * @return the builders in the list + */ + public List getBuilderList() { + if (externalBuilderList == null) { + externalBuilderList = new BuilderExternalList(this); + } + return externalBuilderList; + } + + /** + * Gets a view of the builder as a list of MessageOrBuilders. This returned list is live and will + * reflect any changes to the underlying builder. + * + * @return the builders in the list + */ + public List getMessageOrBuilderList() { + if (externalMessageOrBuilderList == null) { + externalMessageOrBuilderList = new MessageOrBuilderExternalList(this); + } + return externalMessageOrBuilderList; + } + + /** + * Called when a the builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + private void onChanged() { + if (isClean && parent != null) { + parent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + @Override + public void markDirty() { + onChanged(); + } + + /** + * Increments the mod counts so that an ConcurrentModificationException can be thrown if calling + * code tries to modify the builder while its iterating the list. + */ + private void incrementModCounts() { + if (externalMessageList != null) { + externalMessageList.incrementModCount(); + } + if (externalBuilderList != null) { + externalBuilderList.incrementModCount(); + } + if (externalMessageOrBuilderList != null) { + externalMessageOrBuilderList.incrementModCount(); + } + } + + /** + * Provides a live view of the builder as a list of messages. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class MessageExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + MessageExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public MType get(int index) { + return builder.getMessage(index); + } + + void incrementModCount() { + modCount++; + } + } + + /** + * Provides a live view of the builder as a list of builders. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class BuilderExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + BuilderExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public BType get(int index) { + return builder.getBuilder(index); + } + + void incrementModCount() { + modCount++; + } + } + + /** + * Provides a live view of the builder as a list of builders. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class MessageOrBuilderExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + MessageOrBuilderExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public IType get(int index) { + return builder.getMessageOrBuilder(index); + } + + void incrementModCount() { + modCount++; + } + } +} diff --git a/protobuf-api/src/main/java/com/google/protobuf/SerializedForm.java b/protobuf-api/src/main/java/com/google/protobuf/SerializedForm.java new file mode 100644 index 0000000..78b40de --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/SerializedForm.java @@ -0,0 +1,91 @@ +package com.google.protobuf; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * A serialized (serializable) form of the generated message. Stores the message as a class name + * and a byte array. + */ +final class SerializedForm implements Serializable { + + public static SerializedForm of(MessageLite message) { + return new SerializedForm(message); + } + + private static final long serialVersionUID = 0L; + + // since v3.6.1 + private final Class messageClass; + private final String messageClassName; + private final byte[] asBytes; + + /** + * Creates the serialized form by calling {@link com.google.protobuf.MessageLite#toByteArray}. + * + * @param regularForm the message to serialize + */ + SerializedForm(MessageLite regularForm) { + messageClass = regularForm.getClass(); + messageClassName = regularForm.getClass().getName(); + asBytes = regularForm.toByteArray(); + } + + /** + * When read from an ObjectInputStream, this method converts this object back to the regular + * form. Part of Java's serialization magic. + * + * @return a GeneratedMessage of the type that was serialized + */ + protected Object readResolve() throws ObjectStreamException { + try { + Class messageClass = resolveMessageClass(); + java.lang.reflect.Field defaultInstanceField = + messageClass.getDeclaredField("DEFAULT_INSTANCE"); + defaultInstanceField.setAccessible(true); + MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null); + return defaultInstance.newBuilderForType().mergeFrom(asBytes).buildPartial(); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e); + } catch (NoSuchFieldException e) { + return readResolveFallback(); + } catch (SecurityException e) { + throw new RuntimeException("Unable to call DEFAULT_INSTANCE in " + messageClassName, e); + } catch (IllegalAccessException e) { + throw new RuntimeException("Unable to call parsePartialFrom", e); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException("Unable to understand proto buffer", e); + } + } + + /** + * @deprecated from v3.0.0-beta-3+, for compatibility with v2.5.0 and v2.6.1 generated code. + */ + @Deprecated + private Object readResolveFallback() throws ObjectStreamException { + try { + Class messageClass = resolveMessageClass(); + java.lang.reflect.Field defaultInstanceField = + messageClass.getDeclaredField("defaultInstance"); + defaultInstanceField.setAccessible(true); + MessageLite defaultInstance = (MessageLite) defaultInstanceField.get(null); + return defaultInstance.newBuilderForType() + .mergeFrom(asBytes) + .buildPartial(); + } catch (ClassNotFoundException e) { + throw new RuntimeException("Unable to find proto buffer class: " + messageClassName, e); + } catch (NoSuchFieldException e) { + throw new RuntimeException("Unable to find defaultInstance in " + messageClassName, e); + } catch (SecurityException e) { + throw new RuntimeException("Unable to call defaultInstance in " + messageClassName, e); + } catch (IllegalAccessException e) { + throw new RuntimeException("Unable to call parsePartialFrom", e); + } catch (InvalidProtocolBufferException e) { + throw new RuntimeException("Unable to understand proto buffer", e); + } + } + + private Class resolveMessageClass() throws ClassNotFoundException { + return messageClass != null ? messageClass : Class.forName(messageClassName); + } +} \ No newline at end of file diff --git a/protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3Internal.java b/protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3Internal.java new file mode 100644 index 0000000..49a44f6 --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3Internal.java @@ -0,0 +1,217 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf; + +import static com.google.protobuf.Internal.checkNotNull; + +/** + * {@code SingleFieldBuilderV3} implements a structure that a protocol message uses to hold a single + * field of another protocol message. It supports the classical use case of setting an immutable + * {@link Message} as the value of the field and is highly optimized around this. + * + *

It also supports the additional use case of setting a {@link Message.Builder} as the field and + * deferring conversion of that {@code Builder} to an immutable {@code Message}. In this way, it's + * possible to maintain a tree of {@code Builder}'s that acts as a fully read/write data structure. + *
+ * Logically, one can think of a tree of builders as converting the entire tree to messages when + * build is called on the root or when any method is called that desires a Message instead of a + * Builder. In terms of the implementation, the {@code SingleFieldBuilderV3} and {@code + * RepeatedFieldBuilderV3} classes cache messages that were created so that messages only need to be + * created when some change occurred in its builder or a builder for one of its descendants. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + * @author jonp@google.com (Jon Perlow) + */ +class SingleFieldBuilderV3Internal< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + implements Message.BuilderParent { + + // Parent to send changes to. + private Message.BuilderParent parent; + + // Invariant: one of builder or message fields must be non-null. + + // If set, this is the case where we are backed by a builder. In this case, + // message field represents a cached message for the builder (or null if + // there is no cached message). + private BType builder; + + // If builder is non-null, this represents a cached message from the builder. + // If builder is null, this is the authoritative message for the field. + private MType message; + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + private boolean isClean; + + public SingleFieldBuilderV3Internal(MType message, Message.BuilderParent parent, boolean isClean) { + this.message = checkNotNull(message); + this.parent = parent; + this.isClean = isClean; + } + + public void dispose() { + // Null out parent so we stop sending it invalidations. + parent = null; + } + + /** + * Get the message for the field. If the message is currently stored as a {@code Builder}, it is + * converted to a {@code Message} by calling {@link Message.Builder#buildPartial} on it. If no + * message has been set, returns the default instance of the message. + * + * @return the message for the field + */ + @SuppressWarnings("unchecked") + public MType getMessage() { + if (message == null) { + // If message is null, the invariant is that we must be have a builder. + message = (MType) builder.buildPartial(); + } + return message; + } + + /** + * Builds the message and returns it. + * + * @return the message + */ + public MType build() { + // Now that build has been called, we are required to dispatch + // invalidations. + isClean = true; + return getMessage(); + } + + /** + * Gets a builder for the field. If no builder has been created yet, a builder is created on + * demand by calling {@link Message#toBuilder}. + * + * @return The builder for the field + */ + @SuppressWarnings("unchecked") + public BType getBuilder() { + if (builder == null) { + // builder.mergeFrom() on a fresh builder + // does not create any sub-objects with independent clean/dirty states, + // therefore setting the builder itself to clean without actually calling + // build() cannot break any invariants. + builder = (BType) message.newBuilderForType(); + builder.mergeFrom(message); // no-op if message is the default message +// builder.markClean(); + } + return builder; + } + + /** + * Gets the base class interface for the field. This may either be a builder or a message. It will + * return whatever is more efficient. + * + * @return the message or builder for the field as the base class interface + */ + @SuppressWarnings("unchecked") + public IType getMessageOrBuilder() { + if (builder != null) { + return (IType) builder; + } else { + return (IType) message; + } + } + + /** + * Sets a message for the field replacing any existing value. + * + * @param message the message to set + * @return the builder + */ + @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal setMessage(MType message) { + this.message = checkNotNull(message); + if (builder != null) { +// builder.dispose(); + builder = null; + } + onChanged(); + return this; + } + + /** + * Merges the field from another field. + * + * @param value the value to merge from + * @return the builder + */ + @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal mergeFrom(MType value) { + if (builder == null && message == message.getDefaultInstanceForType()) { + message = value; + } else { + getBuilder().mergeFrom(value); + } + onChanged(); + return this; + } + + /** + * Clears the value of the field. + * + * @return the builder + */ + @SuppressWarnings("unchecked") + @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal clear() { + message = + (MType) + (message != null + ? message.getDefaultInstanceForType() + : builder.getDefaultInstanceForType()); + if (builder != null) { +// builder.dispose(); + builder = null; + } + onChanged(); + // After clearing, parent is dirty, but this field builder is now clean and any changes should + // trickle up. + isClean = true; + return this; + } + + /** + * Called when a the builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + private void onChanged() { + // If builder is null, this is the case where onChanged is being called + // from setMessage or clear. + if (builder != null) { + message = null; + } + if (isClean && parent != null) { + parent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + + @Override + public void markDirty() { + onChanged(); + } +} diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/SourceContext.java b/protobuf-api/src/main/java/com/google/protobuf/SourceContext.java similarity index 93% rename from protobuf-sdk/src/main/java/com/google/protobuf/SourceContext.java rename to protobuf-api/src/main/java/com/google/protobuf/SourceContext.java index 38c29b8..059b3ec 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/SourceContext.java +++ b/protobuf-api/src/main/java/com/google/protobuf/SourceContext.java @@ -13,12 +13,12 @@ * Protobuf type {@code google.protobuf.SourceContext} */ public final class SourceContext extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.FlattenedGeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:google.protobuf.SourceContext) SourceContextOrBuilder { private static final long serialVersionUID = 0L; // Use SourceContext.newBuilder() to construct. - private SourceContext(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private SourceContext(com.google.protobuf.FlattenedGeneratedMessageV3.Builder builder) { super(builder); } private SourceContext() { @@ -38,7 +38,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.FlattenedGeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.SourceContextProto.internal_static_google_protobuf_SourceContext_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -108,8 +108,8 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fileName_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, fileName_); + if (!com.google.protobuf.FlattenedGeneratedMessageV3.isStringEmpty(fileName_)) { + com.google.protobuf.FlattenedGeneratedMessageV3.writeString(output, 1, fileName_); } getUnknownFields().writeTo(output); } @@ -120,8 +120,8 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(fileName_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, fileName_); + if (!com.google.protobuf.FlattenedGeneratedMessageV3.isStringEmpty(fileName_)) { + size += com.google.protobuf.FlattenedGeneratedMessageV3.computeStringSize(1, fileName_); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; @@ -192,20 +192,20 @@ public static com.google.protobuf.SourceContext parseFrom( } public static com.google.protobuf.SourceContext parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseWithIOException(PARSER, input); } public static com.google.protobuf.SourceContext parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.SourceContext parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input); } @@ -213,20 +213,20 @@ public static com.google.protobuf.SourceContext parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.SourceContext parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseWithIOException(PARSER, input); } public static com.google.protobuf.SourceContext parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.FlattenedGeneratedMessageV3 .parseWithIOException(PARSER, input, extensionRegistry); } @@ -246,7 +246,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.FlattenedGeneratedMessageV3.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -259,7 +259,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.SourceContext} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.FlattenedGeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.SourceContext) com.google.protobuf.SourceContextOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -268,7 +268,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.FlattenedGeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.SourceContextProto.internal_static_google_protobuf_SourceContext_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -281,7 +281,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.FlattenedGeneratedMessageV3.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/SourceContextOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/SourceContextOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/SourceContextOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/SourceContextOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/SourceContextProto.java b/protobuf-api/src/main/java/com/google/protobuf/SourceContextProto.java similarity index 93% rename from protobuf-sdk/src/main/java/com/google/protobuf/SourceContextProto.java rename to protobuf-api/src/main/java/com/google/protobuf/SourceContextProto.java index 0fdadc4..e8aa94d 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/SourceContextProto.java +++ b/protobuf-api/src/main/java/com/google/protobuf/SourceContextProto.java @@ -18,7 +18,7 @@ public static void registerAllExtensions( static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_SourceContext_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.FlattenedGeneratedMessageV3.FieldAccessorTable internal_static_google_protobuf_SourceContext_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -43,7 +43,7 @@ public static void registerAllExtensions( internal_static_google_protobuf_SourceContext_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_protobuf_SourceContext_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.FlattenedGeneratedMessageV3.FieldAccessorTable( internal_static_google_protobuf_SourceContext_descriptor, new java.lang.String[] { "FileName", }); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/StringValue.java b/protobuf-api/src/main/java/com/google/protobuf/StringValue.java similarity index 93% rename from protobuf-sdk/src/main/java/com/google/protobuf/StringValue.java rename to protobuf-api/src/main/java/com/google/protobuf/StringValue.java index c5ef53e..d9d3615 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/StringValue.java +++ b/protobuf-api/src/main/java/com/google/protobuf/StringValue.java @@ -14,12 +14,12 @@ * Protobuf type {@code google.protobuf.StringValue} */ public final class StringValue extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.StringValue) StringValueOrBuilder { private static final long serialVersionUID = 0L; // Use StringValue.newBuilder() to construct. - private StringValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private StringValue(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private StringValue() { @@ -39,7 +39,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_StringValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -107,8 +107,8 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(value_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, value_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(value_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, value_); } getUnknownFields().writeTo(output); } @@ -119,8 +119,8 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(value_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, value_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(value_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, value_); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; @@ -191,20 +191,20 @@ public static com.google.protobuf.StringValue parseFrom( } public static com.google.protobuf.StringValue parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.StringValue parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.StringValue parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -212,20 +212,20 @@ public static com.google.protobuf.StringValue parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.StringValue parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.StringValue parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -245,7 +245,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -259,7 +259,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.StringValue} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.StringValue) com.google.protobuf.StringValueOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -268,7 +268,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.WrappersProto.internal_static_google_protobuf_StringValue_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -281,7 +281,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/StringValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/StringValueOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/StringValueOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/StringValueOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Struct.java b/protobuf-api/src/main/java/com/google/protobuf/Struct.java similarity index 96% rename from protobuf-sdk/src/main/java/com/google/protobuf/Struct.java rename to protobuf-api/src/main/java/com/google/protobuf/Struct.java index 886142c..387e27b 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Struct.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Struct.java @@ -19,12 +19,12 @@ * Protobuf type {@code google.protobuf.Struct} */ public final class Struct extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Struct) StructOrBuilder { private static final long serialVersionUID = 0L; // Use Struct.newBuilder() to construct. - private Struct(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Struct(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Struct() { @@ -55,7 +55,7 @@ protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldRefl } } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.StructProto.internal_static_google_protobuf_Struct_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -171,7 +171,7 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - com.google.protobuf.GeneratedMessageV3 + com.google.protobuf.GeneratedMessageV3Internal .serializeStringMapTo( output, internalGetFields(), @@ -267,20 +267,20 @@ public static com.google.protobuf.Struct parseFrom( } public static com.google.protobuf.Struct parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Struct parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Struct parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -288,20 +288,20 @@ public static com.google.protobuf.Struct parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Struct parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Struct parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -321,7 +321,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -340,7 +340,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Struct} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Struct) com.google.protobuf.StructOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -371,7 +371,7 @@ protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFi } } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.StructProto.internal_static_google_protobuf_Struct_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -384,7 +384,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/StructOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/StructOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/StructOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/StructOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/StructProto.java b/protobuf-api/src/main/java/com/google/protobuf/StructProto.java similarity index 88% rename from protobuf-sdk/src/main/java/com/google/protobuf/StructProto.java rename to protobuf-api/src/main/java/com/google/protobuf/StructProto.java index 5f0050f..42bb4dd 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/StructProto.java +++ b/protobuf-api/src/main/java/com/google/protobuf/StructProto.java @@ -18,22 +18,22 @@ public static void registerAllExtensions( static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_Struct_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_Struct_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_Struct_FieldsEntry_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_Struct_FieldsEntry_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_Value_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_Value_fieldAccessorTable; static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_ListValue_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_ListValue_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -68,25 +68,25 @@ public static void registerAllExtensions( internal_static_google_protobuf_Struct_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_protobuf_Struct_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_Struct_descriptor, new java.lang.String[] { "Fields", }); internal_static_google_protobuf_Struct_FieldsEntry_descriptor = internal_static_google_protobuf_Struct_descriptor.getNestedTypes().get(0); internal_static_google_protobuf_Struct_FieldsEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_Struct_FieldsEntry_descriptor, new java.lang.String[] { "Key", "Value", }); internal_static_google_protobuf_Value_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_google_protobuf_Value_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_Value_descriptor, new java.lang.String[] { "NullValue", "NumberValue", "StringValue", "BoolValue", "StructValue", "ListValue", "Kind", }); internal_static_google_protobuf_ListValue_descriptor = getDescriptor().getMessageTypes().get(2); internal_static_google_protobuf_ListValue_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_ListValue_descriptor, new java.lang.String[] { "Values", }); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Syntax.java b/protobuf-api/src/main/java/com/google/protobuf/Syntax.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/Syntax.java rename to protobuf-api/src/main/java/com/google/protobuf/Syntax.java diff --git a/protobuf-api/src/main/java/com/google/protobuf/TextFormatEscaper.java b/protobuf-api/src/main/java/com/google/protobuf/TextFormatEscaper.java index 8e43fb0..772700c 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/TextFormatEscaper.java +++ b/protobuf-api/src/main/java/com/google/protobuf/TextFormatEscaper.java @@ -7,6 +7,8 @@ package com.google.protobuf; +import java.io.IOException; + /** * Provide text format escaping of proto instances. These ASCII characters are escaped: * @@ -25,7 +27,7 @@ * Other ASCII characters less than 32 and all Unicode characters 128 or greater are * first encoded as UTF-8, then each byte is escaped individually as a 3-digit octal escape. */ -final class TextFormatEscaper { +public final class TextFormatEscaper { private TextFormatEscaper() {} private interface ByteSequence { @@ -37,7 +39,7 @@ private interface ByteSequence { /** * Backslash escapes bytes in the format used in protocol buffer text format. */ - static String escapeBytes(ByteSequence input) { + public static String escapeBytes(ByteSequence input) { final StringBuilder builder = new StringBuilder(input.size()); for (int i = 0; i < input.size(); i++) { byte b = input.byteAt(i); @@ -126,12 +128,222 @@ public byte byteAt(int offset) { /** * Like {@link #escapeBytes(ByteString)}, but escapes a text string. */ - static String escapeText(String input) { + public static String escapeText(String input) { return escapeBytes(ByteString.copyFromUtf8(input)); } /** Escape double quotes and backslashes in a String for unicode output of a message. */ - static String escapeDoubleQuotesAndBackslashes(String input) { + public static String escapeDoubleQuotesAndBackslashes(String input) { return input.replace("\\", "\\\\").replace("\"", "\\\""); } + + /** Is this an octal digit? */ + private static boolean isOctal(final byte c) { + return '0' <= c && c <= '7'; + } + + /** Is this a hex digit? */ + private static boolean isHex(final byte c) { + return ('0' <= c && c <= '9') || ('a' <= c && c <= 'f') || ('A' <= c && c <= 'F'); + } + + /** + * Interpret a character as a digit (in any base up to 36) and return the numeric value. This is + * like {@code Character.digit()} but we don't accept non-ASCII digits. + */ + private static int digitValue(final byte c) { + if ('0' <= c && c <= '9') { + return c - '0'; + } else if ('a' <= c && c <= 'z') { + return c - 'a' + 10; + } else { + return c - 'A' + 10; + } + } + + /** + * Thrown by {@link TextFormat#unescapeBytes} and {@link TextFormat#unescapeText} when an invalid + * escape sequence is seen. + */ + public static class InvalidEscapeSequenceException extends IOException { + private static final long serialVersionUID = -8164033650142593305L; + + InvalidEscapeSequenceException(final String description) { + super(description); + } + } + + public static ByteString unescapeBytes(CharSequence charString) + throws TextFormatEscaper.InvalidEscapeSequenceException { + // First convert the Java character sequence to UTF-8 bytes. + ByteString input = ByteString.copyFromUtf8(charString.toString()); + // Then unescape certain byte sequences introduced by ASCII '\\'. The valid + // escapes can all be expressed with ASCII characters, so it is safe to + // operate on bytes here. + // + // Unescaping the input byte array will result in a byte sequence that's no + // longer than the input. That's because each escape sequence is between + // two and four bytes long and stands for a single byte. + final byte[] result = new byte[input.size()]; + int pos = 0; + for (int i = 0; i < input.size(); i++) { + byte c = input.byteAt(i); + if (c == '\\') { + if (i + 1 < input.size()) { + ++i; + c = input.byteAt(i); + if (isOctal(c)) { + // Octal escape. + int code = digitValue(c); + if (i + 1 < input.size() && isOctal(input.byteAt(i + 1))) { + ++i; + code = code * 8 + digitValue(input.byteAt(i)); + } + if (i + 1 < input.size() && isOctal(input.byteAt(i + 1))) { + ++i; + code = code * 8 + digitValue(input.byteAt(i)); + } + // TODO: Check that 0 <= code && code <= 0xFF. + result[pos++] = (byte) code; + } else { + switch (c) { + case 'a': + result[pos++] = 0x07; + break; + case 'b': + result[pos++] = '\b'; + break; + case 'f': + result[pos++] = '\f'; + break; + case 'n': + result[pos++] = '\n'; + break; + case 'r': + result[pos++] = '\r'; + break; + case 't': + result[pos++] = '\t'; + break; + case 'v': + result[pos++] = 0x0b; + break; + case '\\': + result[pos++] = '\\'; + break; + case '\'': + result[pos++] = '\''; + break; + case '"': + result[pos++] = '\"'; + break; + case '?': + result[pos++] = '?'; + break; + + case 'x': + // hex escape + int code = 0; + if (i + 1 < input.size() && isHex(input.byteAt(i + 1))) { + ++i; + code = digitValue(input.byteAt(i)); + } else { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\x' with no digits"); + } + if (i + 1 < input.size() && isHex(input.byteAt(i + 1))) { + ++i; + code = code * 16 + digitValue(input.byteAt(i)); + } + result[pos++] = (byte) code; + break; + + case 'u': + // Unicode escape + ++i; + if (i + 3 < input.size() + && isHex(input.byteAt(i)) + && isHex(input.byteAt(i + 1)) + && isHex(input.byteAt(i + 2)) + && isHex(input.byteAt(i + 3))) { + char ch = + (char) + (digitValue(input.byteAt(i)) << 12 + | digitValue(input.byteAt(i + 1)) << 8 + | digitValue(input.byteAt(i + 2)) << 4 + | digitValue(input.byteAt(i + 3))); + + if (ch >= Character.MIN_SURROGATE && ch <= Character.MAX_SURROGATE) { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\u' refers to a surrogate"); + } + byte[] chUtf8 = Character.toString(ch).getBytes(Internal.UTF_8); + System.arraycopy(chUtf8, 0, result, pos, chUtf8.length); + pos += chUtf8.length; + i += 3; + } else { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\u' with too few hex chars"); + } + break; + + case 'U': + // Unicode escape + ++i; + if (i + 7 >= input.size()) { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\U' with too few hex chars"); + } + int codepoint = 0; + for (int offset = i; offset < i + 8; offset++) { + byte b = input.byteAt(offset); + if (!isHex(b)) { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\U' with too few hex chars"); + } + codepoint = (codepoint << 4) | digitValue(b); + } + if (!Character.isValidCodePoint(codepoint)) { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\U" + + input.substring(i, i + 8).toStringUtf8() + + "' is not a valid code point value"); + } + Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint); + if (unicodeBlock != null + && (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES) + || unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES) + || unicodeBlock.equals( + Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\U" + + input.substring(i, i + 8).toStringUtf8() + + "' refers to a surrogate code unit"); + } + int[] codepoints = new int[1]; + codepoints[0] = codepoint; + byte[] chUtf8 = new String(codepoints, 0, 1).getBytes(Internal.UTF_8); + System.arraycopy(chUtf8, 0, result, pos, chUtf8.length); + pos += chUtf8.length; + i += 7; + break; + + default: + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\" + (char) c + '\''); + } + } + } else { + throw new TextFormatEscaper.InvalidEscapeSequenceException( + "Invalid escape sequence: '\\' at end of string."); + } + } else { + result[pos++] = c; + } + } + + return result.length == pos + ? ByteString.wrap(result) // This reference has not been out of our control. + : ByteString.copyFrom(result, 0, pos); + } } diff --git a/protobuf-api/src/main/java/com/google/protobuf/TextFormatInternal.java b/protobuf-api/src/main/java/com/google/protobuf/TextFormatInternal.java new file mode 100644 index 0000000..e5b08de --- /dev/null +++ b/protobuf-api/src/main/java/com/google/protobuf/TextFormatInternal.java @@ -0,0 +1,732 @@ +package com.google.protobuf; + +import java.io.IOException; +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +public class TextFormatInternal { + /** + * Parse a 32-bit signed integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal + * and octal numbers, respectively. + */ + static int parseInt32(final String text) throws NumberFormatException { + return (int) parseInteger(text, true, false); + } + + /** + * Parse a 32-bit unsigned integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal + * and octal numbers, respectively. The result is coerced to a (signed) {@code int} when returned + * since Java has no unsigned integer type. + */ + static int parseUInt32(final String text) throws NumberFormatException { + return (int) parseInteger(text, false, false); + } + + /** + * Parse a 64-bit signed integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal + * and octal numbers, respectively. + */ + static long parseInt64(final String text) throws NumberFormatException { + return parseInteger(text, true, true); + } + + /** + * Parse a 64-bit unsigned integer from the text. Unlike the Java standard {@code + * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal + * and octal numbers, respectively. The result is coerced to a (signed) {@code long} when returned + * since Java has no unsigned long type. + */ + static long parseUInt64(final String text) throws NumberFormatException { + return parseInteger(text, false, true); + } + + private static long parseInteger(final String text, final boolean isSigned, final boolean isLong) + throws NumberFormatException { + int pos = 0; + + boolean negative = false; + if (text.startsWith("-", pos)) { + if (!isSigned) { + throw new NumberFormatException("Number must be positive: " + text); + } + ++pos; + negative = true; + } + + int radix = 10; + if (text.startsWith("0x", pos)) { + pos += 2; + radix = 16; + } else if (text.startsWith("0", pos)) { + radix = 8; + } + + final String numberText = text.substring(pos); + + long result = 0; + if (numberText.length() < 16) { + // Can safely assume no overflow. + result = Long.parseLong(numberText, radix); + if (negative) { + result = -result; + } + + // Check bounds. + // No need to check for 64-bit numbers since they'd have to be 16 chars + // or longer to overflow. + if (!isLong) { + if (isSigned) { + if (result > Integer.MAX_VALUE || result < Integer.MIN_VALUE) { + throw new NumberFormatException( + "Number out of range for 32-bit signed integer: " + text); + } + } else { + if (result >= (1L << 32) || result < 0) { + throw new NumberFormatException( + "Number out of range for 32-bit unsigned integer: " + text); + } + } + } + } else { + BigInteger bigValue = new BigInteger(numberText, radix); + if (negative) { + bigValue = bigValue.negate(); + } + + // Check bounds. + if (!isLong) { + if (isSigned) { + if (bigValue.bitLength() > 31) { + throw new NumberFormatException( + "Number out of range for 32-bit signed integer: " + text); + } + } else { + if (bigValue.bitLength() > 32) { + throw new NumberFormatException( + "Number out of range for 32-bit unsigned integer: " + text); + } + } + } else { + if (isSigned) { + if (bigValue.bitLength() > 63) { + throw new NumberFormatException( + "Number out of range for 64-bit signed integer: " + text); + } + } else { + if (bigValue.bitLength() > 64) { + throw new NumberFormatException( + "Number out of range for 64-bit unsigned integer: " + text); + } + } + } + + result = bigValue.longValue(); + } + + return result; + } + + /** Printer instance which escapes non-ASCII characters. */ + public static TextFormatInternal.Printer printer() { + return TextFormatInternal.Printer.DEFAULT; + } + + /** Helper class for converting protobufs to text. */ + public static final class Printer { + + // Printer instance which escapes non-ASCII characters. + private static final TextFormatInternal.Printer DEFAULT = new TextFormatInternal.Printer(true, TypeRegistry.getEmptyTypeRegistry()); + + /** Whether to escape non ASCII characters with backslash and octal. */ + private final boolean escapeNonAscii; + + private final TypeRegistry typeRegistry; + + private Printer(boolean escapeNonAscii, TypeRegistry typeRegistry) { + this.escapeNonAscii = escapeNonAscii; + this.typeRegistry = typeRegistry; + } + + /** + * Return a new Printer instance with the specified escape mode. + * + * @param escapeNonAscii If true, the new Printer will escape non-ASCII characters (this is the + * default behavior. If false, the new Printer will print non-ASCII characters as is. In + * either case, the new Printer still escapes newlines and quotes in strings. + * @return a new Printer that clones all other configurations from the current {@link TextFormatInternal.Printer}, + * with the escape mode set to the given parameter. + */ + public TextFormatInternal.Printer escapingNonAscii(boolean escapeNonAscii) { + return new TextFormatInternal.Printer(escapeNonAscii, typeRegistry); + } + + /** + * Creates a new {@link TextFormatInternal.Printer} using the given typeRegistry. The new Printer clones all other + * configurations from the current {@link TextFormatInternal.Printer}. + * + * @throws IllegalArgumentException if a registry is already set. + */ + public TextFormatInternal.Printer usingTypeRegistry(TypeRegistry typeRegistry) { + if (this.typeRegistry != TypeRegistry.getEmptyTypeRegistry()) { + throw new IllegalArgumentException("Only one typeRegistry is allowed."); + } + return new TextFormatInternal.Printer(escapeNonAscii, typeRegistry); + } + + /** + * Outputs a textual representation of the Protocol Message supplied into the parameter output. + * (This representation is the new version of the classic "ProtocolPrinter" output from the + * original Protocol Buffer system) + */ + public void print(final MessageOrBuilder message, final Appendable output) throws IOException { + print(message, multiLineOutput(output)); + } + + /** Outputs a textual representation of {@code fields} to {@code output}. */ + public void print(final UnknownFieldSet fields, final Appendable output) throws IOException { + printUnknownFields(fields, multiLineOutput(output)); + } + + private void print(final MessageOrBuilder message, final TextFormatInternal.TextGenerator generator) + throws IOException { + if (message.getDescriptorForType().getFullName().equals("google.protobuf.Any") + && printAny(message, generator)) { + return; + } + printMessage(message, generator); + } + + /** + * Attempt to print the 'google.protobuf.Any' message in a human-friendly format. Returns false + * if the message isn't a valid 'google.protobuf.Any' message (in which case the message should + * be rendered just like a regular message to help debugging). + */ + private boolean printAny(final MessageOrBuilder message, final TextFormatInternal.TextGenerator generator) + throws IOException { + Descriptors.Descriptor messageType = message.getDescriptorForType(); + Descriptors.FieldDescriptor typeUrlField = messageType.findFieldByNumber(1); + Descriptors.FieldDescriptor valueField = messageType.findFieldByNumber(2); + if (typeUrlField == null + || typeUrlField.getType() != Descriptors.FieldDescriptor.Type.STRING + || valueField == null + || valueField.getType() != Descriptors.FieldDescriptor.Type.BYTES) { + // The message may look like an Any but isn't actually an Any message (might happen if the + // user tries to use DynamicMessage to construct an Any from incomplete Descriptor). + return false; + } + String typeUrl = (String) message.getField(typeUrlField); + // If type_url is not set, we will not be able to decode the content of the value, so just + // print out the Any like a regular message. + if (typeUrl.isEmpty()) { + return false; + } + Object value = message.getField(valueField); + + Message.Builder contentBuilder = null; + try { + Descriptors.Descriptor contentType = typeRegistry.getDescriptorForTypeUrl(typeUrl); + if (contentType == null) { + return false; + } + contentBuilder = DynamicMessage.getDefaultInstance(contentType).newBuilderForType(); + contentBuilder.mergeFrom((ByteString) value); + } catch (InvalidProtocolBufferException e) { + // The value of Any is malformed. We cannot print it out nicely, so fallback to printing out + // the type_url and value as bytes. Note that we fail open here to be consistent with + // text_format.cc, and also to allow a way for users to inspect the content of the broken + // message. + return false; + } + generator.print("["); + generator.print(typeUrl); + generator.print("] {"); + generator.eol(); + generator.indent(); + print(contentBuilder, generator); + generator.outdent(); + generator.print("}"); + generator.eol(); + return true; + } + + public String printFieldToString(final Descriptors.FieldDescriptor field, final Object value) { + try { + final StringBuilder text = new StringBuilder(); + printField(field, value, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + public void printField(final Descriptors.FieldDescriptor field, final Object value, final Appendable output) + throws IOException { + printField(field, value, multiLineOutput(output)); + } + + private void printField( + final Descriptors.FieldDescriptor field, final Object value, final TextFormatInternal.TextGenerator generator) + throws IOException { + // Sort map field entries by key + if (field.isMapField()) { + List adapters = new ArrayList<>(); + for (Object entry : (List) value) { + adapters.add(new TextFormatInternal.Printer.MapEntryAdapter(entry, field)); + } + Collections.sort(adapters); + for (TextFormatInternal.Printer.MapEntryAdapter adapter : adapters) { + printSingleField(field, adapter.getEntry(), generator); + } + } else if (field.isRepeated()) { + // Repeated field. Print each element. + for (Object element : (List) value) { + printSingleField(field, element, generator); + } + } else { + printSingleField(field, value, generator); + } + } + + /** An adapter class that can take a {@link MapEntry} and returns its key and entry. */ + private static class MapEntryAdapter implements Comparable { + private Object entry; + + @SuppressWarnings({"rawtypes"}) + private MapEntry mapEntry; + + private final Descriptors.FieldDescriptor.JavaType fieldType; + + MapEntryAdapter(Object entry, Descriptors.FieldDescriptor fieldDescriptor) { + if (entry instanceof MapEntry) { + this.mapEntry = (MapEntry) entry; + } else { + this.entry = entry; + } + this.fieldType = extractFieldType(fieldDescriptor); + } + + private static Descriptors.FieldDescriptor.JavaType extractFieldType(Descriptors.FieldDescriptor fieldDescriptor) { + return fieldDescriptor.getMessageType().getFields().get(0).getJavaType(); + } + + Object getKey() { + if (mapEntry != null) { + return mapEntry.getKey(); + } + return null; + } + + Object getEntry() { + if (mapEntry != null) { + return mapEntry; + } + return entry; + } + + @Override + public int compareTo(TextFormatInternal.Printer.MapEntryAdapter b) { + if (getKey() == null || b.getKey() == null) { +// logger.info("Invalid key for map field."); + return -1; + } + switch (fieldType) { + case BOOLEAN: + return Boolean.valueOf((boolean) getKey()).compareTo((boolean) b.getKey()); + case LONG: + return Long.valueOf((long) getKey()).compareTo((long) b.getKey()); + case INT: + return Integer.valueOf((int) getKey()).compareTo((int) b.getKey()); + case STRING: + String aString = (String) getKey(); + String bString = (String) b.getKey(); + if (aString == null && bString == null) { + return 0; + } else if (aString == null && bString != null) { + return -1; + } else if (aString != null && bString == null) { + return 1; + } else { + return aString.compareTo(bString); + } + default: + return 0; + } + } + } + + /** + * Outputs a textual representation of the value of given field value. + * + * @param field the descriptor of the field + * @param value the value of the field + * @param output the output to which to append the formatted value + * @throws ClassCastException if the value is not appropriate for the given field descriptor + * @throws IOException if there is an exception writing to the output + */ + public void printFieldValue( + final Descriptors.FieldDescriptor field, final Object value, final Appendable output) + throws IOException { + printFieldValue(field, value, multiLineOutput(output)); + } + + private void printFieldValue( + final Descriptors.FieldDescriptor field, final Object value, final TextFormatInternal.TextGenerator generator) + throws IOException { + switch (field.getType()) { + case INT32: + case SINT32: + case SFIXED32: + generator.print(((Integer) value).toString()); + break; + + case INT64: + case SINT64: + case SFIXED64: + generator.print(((Long) value).toString()); + break; + + case BOOL: + generator.print(((Boolean) value).toString()); + break; + + case FLOAT: + generator.print(((Float) value).toString()); + break; + + case DOUBLE: + generator.print(((Double) value).toString()); + break; + + case UINT32: + case FIXED32: + generator.print(unsignedToString((Integer) value)); + break; + + case UINT64: + case FIXED64: + generator.print(unsignedToString((Long) value)); + break; + + case STRING: + generator.print("\""); + generator.print( + escapeNonAscii + ? TextFormatEscaper.escapeText((String) value) + : escapeDoubleQuotesAndBackslashes((String) value).replace("\n", "\\n")); + generator.print("\""); + break; + + case BYTES: + generator.print("\""); + if (value instanceof ByteString) { + generator.print(escapeBytes((ByteString) value)); + } else { + generator.print(escapeBytes((byte[]) value)); + } + generator.print("\""); + break; + + case ENUM: + generator.print(((Descriptors.EnumValueDescriptor) value).getName()); + break; + + case MESSAGE: + case GROUP: + print((MessageOrBuilder) value, generator); + break; + } + } + + /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + public String printToString(final MessageOrBuilder message) { + try { + final StringBuilder text = new StringBuilder(); + print(message, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + /** Like {@code print()}, but writes directly to a {@code String} and returns it. */ + public String printToString(final UnknownFieldSet fields) { + try { + final StringBuilder text = new StringBuilder(); + print(fields, text); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of this message, useful for debugging and other purposes, + * with no newline characters. + */ + public String shortDebugString(final MessageOrBuilder message) { + try { + final StringBuilder text = new StringBuilder(); + print(message, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of the field, useful for debugging and other purposes, with + * no newline characters. + */ + public String shortDebugString(final Descriptors.FieldDescriptor field, final Object value) { + try { + final StringBuilder text = new StringBuilder(); + printField(field, value, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + /** + * Generates a human readable form of the unknown fields, useful for debugging and other + * purposes, with no newline characters. + */ + public String shortDebugString(final UnknownFieldSet fields) { + try { + final StringBuilder text = new StringBuilder(); + printUnknownFields(fields, singleLineOutput(text)); + return text.toString(); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } + + private static void printUnknownFieldValue( + final int tag, final Object value, final TextFormatInternal.TextGenerator generator) throws IOException { + switch (WireFormat.getTagWireType(tag)) { + case WireFormat.WIRETYPE_VARINT: + generator.print(unsignedToString((Long) value)); + break; + case WireFormat.WIRETYPE_FIXED32: + generator.print(String.format((Locale) null, "0x%08x", (Integer) value)); + break; + case WireFormat.WIRETYPE_FIXED64: + generator.print(String.format((Locale) null, "0x%016x", (Long) value)); + break; + case WireFormat.WIRETYPE_LENGTH_DELIMITED: + try { + // Try to parse and print the field as an embedded message + UnknownFieldSet message = UnknownFieldSet.parseFrom((ByteString) value); + generator.print("{"); + generator.eol(); + generator.indent(); + printUnknownFields(message, generator); + generator.outdent(); + generator.print("}"); + } catch (InvalidProtocolBufferException e) { + // If not parseable as a message, print as a String + generator.print("\""); + generator.print(escapeBytes((ByteString) value)); + generator.print("\""); + } + break; + case WireFormat.WIRETYPE_START_GROUP: + printUnknownFields((UnknownFieldSet) value, generator); + break; + default: + throw new IllegalArgumentException("Bad tag: " + tag); + } + } + + private void printMessage(final MessageOrBuilder message, final TextFormatInternal.TextGenerator generator) + throws IOException { + for (Map.Entry field : message.getAllFields().entrySet()) { + printField(field.getKey(), field.getValue(), generator); + } + printUnknownFields(message.getUnknownFields(), generator); + } + + private void printSingleField( + final Descriptors.FieldDescriptor field, final Object value, final TextFormatInternal.TextGenerator generator) + throws IOException { + if (field.isExtension()) { + generator.print("["); + // We special-case MessageSet elements for compatibility with proto1. + if (field.getContainingType().getOptions().getMessageSetWireFormat() + && (field.getType() == Descriptors.FieldDescriptor.Type.MESSAGE) + && (field.isOptional()) + // object equality + && (field.getExtensionScope() == field.getMessageType())) { + generator.print(field.getMessageType().getFullName()); + } else { + generator.print(field.getFullName()); + } + generator.print("]"); + } else { + if (field.getType() == Descriptors.FieldDescriptor.Type.GROUP) { + // Groups must be serialized with their original capitalization. + generator.print(field.getMessageType().getName()); + } else { + generator.print(field.getName()); + } + } + + if (field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) { + generator.print(" {"); + generator.eol(); + generator.indent(); + } else { + generator.print(": "); + } + + printFieldValue(field, value, generator); + + if (field.getJavaType() == Descriptors.FieldDescriptor.JavaType.MESSAGE) { + generator.outdent(); + generator.print("}"); + } + generator.eol(); + } + + private static void printUnknownFields( + final UnknownFieldSet unknownFields, final TextFormatInternal.TextGenerator generator) throws IOException { + for (Map.Entry entry : unknownFields.asMap().entrySet()) { + final int number = entry.getKey(); + final UnknownFieldSet.Field field = entry.getValue(); + printUnknownField(number, WireFormat.WIRETYPE_VARINT, field.getVarintList(), generator); + printUnknownField(number, WireFormat.WIRETYPE_FIXED32, field.getFixed32List(), generator); + printUnknownField(number, WireFormat.WIRETYPE_FIXED64, field.getFixed64List(), generator); + printUnknownField( + number, + WireFormat.WIRETYPE_LENGTH_DELIMITED, + field.getLengthDelimitedList(), + generator); + for (final UnknownFieldSet value : field.getGroupList()) { + generator.print(entry.getKey().toString()); + generator.print(" {"); + generator.eol(); + generator.indent(); + printUnknownFields(value, generator); + generator.outdent(); + generator.print("}"); + generator.eol(); + } + } + } + + private static void printUnknownField( + final int number, final int wireType, final List values, final TextFormatInternal.TextGenerator generator) + throws IOException { + for (final Object value : values) { + generator.print(String.valueOf(number)); + generator.print(": "); + printUnknownFieldValue(wireType, value, generator); + generator.eol(); + } + } + } + + /** Convert an unsigned 32-bit integer to a string. */ + public static String unsignedToString(final int value) { + if (value >= 0) { + return Integer.toString(value); + } else { + return Long.toString(value & 0x00000000FFFFFFFFL); + } + } + + /** Convert an unsigned 64-bit integer to a string. */ + public static String unsignedToString(final long value) { + if (value >= 0) { + return Long.toString(value); + } else { + // Pull off the most-significant bit so that BigInteger doesn't think + // the number is negative, then set it again using setBit(). + return BigInteger.valueOf(value & 0x7FFFFFFFFFFFFFFFL).setBit(63).toString(); + } + } + + private static TextFormatInternal.TextGenerator multiLineOutput(Appendable output) { + return new TextFormatInternal.TextGenerator(output, false); + } + + private static TextFormatInternal.TextGenerator singleLineOutput(Appendable output) { + return new TextFormatInternal.TextGenerator(output, true); + } + + private static String escapeBytes(ByteString input) { + return TextFormatEscaper.escapeBytes(input); + } + + public static String escapeBytes(byte[] input) { + return TextFormatEscaper.escapeBytes(input); + } + + public static String escapeDoubleQuotesAndBackslashes(final String input) { + return TextFormatEscaper.escapeDoubleQuotesAndBackslashes(input); + } + + /** An inner class for writing text to the output stream. */ + private static final class TextGenerator { + private final Appendable output; + private final StringBuilder indent = new StringBuilder(); + private final boolean singleLineMode; + // While technically we are "at the start of a line" at the very beginning of the output, all + // we would do in response to this is emit the (zero length) indentation, so it has no effect. + // Setting it false here does however suppress an unwanted leading space in single-line mode. + private boolean atStartOfLine = false; + + private TextGenerator(final Appendable output, boolean singleLineMode) { + this.output = output; + this.singleLineMode = singleLineMode; + } + + /** + * Indent text by two spaces. After calling Indent(), two spaces will be inserted at the + * beginning of each line of text. Indent() may be called multiple times to produce deeper + * indents. + */ + public void indent() { + indent.append(" "); + } + + /** Reduces the current indent level by two spaces, or crashes if the indent level is zero. */ + public void outdent() { + final int length = indent.length(); + if (length == 0) { + throw new IllegalArgumentException(" Outdent() without matching Indent()."); + } + indent.setLength(length - 2); + } + + /** + * Print text to the output stream. Bare newlines are never expected to be passed to this + * method; to indicate the end of a line, call "eol()". + */ + public void print(final CharSequence text) throws IOException { + if (atStartOfLine) { + atStartOfLine = false; + output.append(singleLineMode ? " " : indent); + } + output.append(text); + } + + /** + * Signifies reaching the "end of the current line" in the output. In single-line mode, this + * does not result in a newline being emitted, but ensures that a separating space is written + * before the next output. + */ + public void eol() throws IOException { + if (!singleLineMode) { + output.append("\n"); + } + atStartOfLine = true; + } + } +} diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Timestamp.java b/protobuf-api/src/main/java/com/google/protobuf/Timestamp.java similarity index 96% rename from protobuf-sdk/src/main/java/com/google/protobuf/Timestamp.java rename to protobuf-api/src/main/java/com/google/protobuf/Timestamp.java index a196076..a494a67 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Timestamp.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Timestamp.java @@ -100,12 +100,12 @@ * Protobuf type {@code google.protobuf.Timestamp} */ public final class Timestamp extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Timestamp) TimestampOrBuilder { private static final long serialVersionUID = 0L; // Use Timestamp.newBuilder() to construct. - private Timestamp(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Timestamp(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Timestamp() { @@ -124,7 +124,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.TimestampProto.internal_static_google_protobuf_Timestamp_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -277,20 +277,20 @@ public static com.google.protobuf.Timestamp parseFrom( } public static com.google.protobuf.Timestamp parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Timestamp parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Timestamp parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -298,20 +298,20 @@ public static com.google.protobuf.Timestamp parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Timestamp parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Timestamp parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -331,7 +331,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -431,7 +431,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Timestamp} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Timestamp) com.google.protobuf.TimestampOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -440,7 +440,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.TimestampProto.internal_static_google_protobuf_Timestamp_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -453,7 +453,7 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/TimestampOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/TimestampOrBuilder.java similarity index 100% rename from protobuf-sdk/src/main/java/com/google/protobuf/TimestampOrBuilder.java rename to protobuf-api/src/main/java/com/google/protobuf/TimestampOrBuilder.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/TimestampProto.java b/protobuf-api/src/main/java/com/google/protobuf/TimestampProto.java similarity index 93% rename from protobuf-sdk/src/main/java/com/google/protobuf/TimestampProto.java rename to protobuf-api/src/main/java/com/google/protobuf/TimestampProto.java index 8cf5af4..2512638 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/TimestampProto.java +++ b/protobuf-api/src/main/java/com/google/protobuf/TimestampProto.java @@ -18,7 +18,7 @@ public static void registerAllExtensions( static final com.google.protobuf.Descriptors.Descriptor internal_static_google_protobuf_Timestamp_descriptor; static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internal_static_google_protobuf_Timestamp_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor @@ -43,7 +43,7 @@ public static void registerAllExtensions( internal_static_google_protobuf_Timestamp_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_google_protobuf_Timestamp_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable( internal_static_google_protobuf_Timestamp_descriptor, new java.lang.String[] { "Seconds", "Nanos", }); } diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Type.java b/protobuf-api/src/main/java/com/google/protobuf/Type.java similarity index 94% rename from protobuf-sdk/src/main/java/com/google/protobuf/Type.java rename to protobuf-api/src/main/java/com/google/protobuf/Type.java index 88b3492..1b70195 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/Type.java +++ b/protobuf-api/src/main/java/com/google/protobuf/Type.java @@ -12,12 +12,12 @@ * Protobuf type {@code google.protobuf.Type} */ public final class Type extends - com.google.protobuf.GeneratedMessageV3 implements + com.google.protobuf.GeneratedMessageV3Internal implements // @@protoc_insertion_point(message_implements:google.protobuf.Type) TypeOrBuilder { private static final long serialVersionUID = 0L; // Use Type.newBuilder() to construct. - private Type(com.google.protobuf.GeneratedMessageV3.Builder builder) { + private Type(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) { super(builder); } private Type() { @@ -43,7 +43,7 @@ protected java.lang.Object newInstance( } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.TypeProto.internal_static_google_protobuf_Type_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -398,14 +398,14 @@ public final boolean isInitialized() { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 1, name_); } for (int i = 0; i < fields_.size(); i++) { output.writeMessage(2, fields_.get(i)); } for (int i = 0; i < oneofs_.size(); i++) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, oneofs_.getRaw(i)); + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, oneofs_.getRaw(i)); } for (int i = 0; i < options_.size(); i++) { output.writeMessage(4, options_.get(i)); @@ -416,8 +416,8 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) if (syntax_ != com.google.protobuf.Syntax.SYNTAX_PROTO2.getNumber()) { output.writeEnum(6, syntax_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(edition_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, edition_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(edition_)) { + com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 7, edition_); } getUnknownFields().writeTo(output); } @@ -428,8 +428,8 @@ public int getSerializedSize() { if (size != -1) return size; size = 0; - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(1, name_); } for (int i = 0; i < fields_.size(); i++) { size += com.google.protobuf.CodedOutputStream @@ -455,8 +455,8 @@ public int getSerializedSize() { size += com.google.protobuf.CodedOutputStream .computeEnumSize(6, syntax_); } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(edition_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, edition_); + if (!com.google.protobuf.GeneratedMessageV3Internal.isStringEmpty(edition_)) { + size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(7, edition_); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; @@ -561,20 +561,20 @@ public static com.google.protobuf.Type parseFrom( } public static com.google.protobuf.Type parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Type parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Type parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input); } @@ -582,20 +582,20 @@ public static com.google.protobuf.Type parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.Type parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input); } public static com.google.protobuf.Type parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 + return com.google.protobuf.GeneratedMessageV3Internal .parseWithIOException(PARSER, input, extensionRegistry); } @@ -615,7 +615,7 @@ public Builder toBuilder() { @java.lang.Override protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } @@ -627,7 +627,7 @@ protected Builder newBuilderForType( * Protobuf type {@code google.protobuf.Type} */ public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements + com.google.protobuf.GeneratedMessageV3Internal.Builder implements // @@protoc_insertion_point(builder_implements:google.protobuf.Type) com.google.protobuf.TypeOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor @@ -636,7 +636,7 @@ public static final class Builder extends } @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable internalGetFieldAccessorTable() { return com.google.protobuf.TypeProto.internal_static_google_protobuf_Type_fieldAccessorTable .ensureFieldAccessorsInitialized( @@ -649,12 +649,12 @@ private Builder() { } private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) { super(parent); maybeForceBuilderInitialization(); } private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 + if (com.google.protobuf.GeneratedMessageV3Internal .alwaysUseFieldBuilders) { getFieldsFieldBuilder(); getOptionsFieldBuilder(); @@ -835,7 +835,7 @@ public Builder mergeFrom(com.google.protobuf.Type other) { fields_ = other.fields_; bitField0_ = (bitField0_ & ~0x00000002); fieldsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getFieldsFieldBuilder() : null; } else { fieldsBuilder_.addAllMessages(other.fields_); @@ -871,7 +871,7 @@ public Builder mergeFrom(com.google.protobuf.Type other) { options_ = other.options_; bitField0_ = (bitField0_ & ~0x00000008); optionsBuilder_ = - com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? + com.google.protobuf.GeneratedMessageV3Internal.alwaysUseFieldBuilders ? getOptionsFieldBuilder() : null; } else { optionsBuilder_.addAllMessages(other.options_); @@ -1087,8 +1087,8 @@ private void ensureFieldsIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< - com.google.protobuf.Field, com.google.protobuf.Field.Builder, com.google.protobuf.FieldOrBuilder> fieldsBuilder_; + private RepeatedFieldBuilderV3Internal< + Field, Field.Builder, FieldOrBuilder> fieldsBuilder_; /** *

@@ -1375,12 +1375,12 @@ public com.google.protobuf.Field.Builder addFieldsBuilder(
          getFieldsBuilderList() {
       return getFieldsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Field, com.google.protobuf.Field.Builder, com.google.protobuf.FieldOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Field, Field.Builder, FieldOrBuilder>
         getFieldsFieldBuilder() {
       if (fieldsBuilder_ == null) {
-        fieldsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Field, com.google.protobuf.Field.Builder, com.google.protobuf.FieldOrBuilder>(
+        fieldsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Field, Field.Builder, FieldOrBuilder>(
                 fields_,
                 ((bitField0_ & 0x00000002) != 0),
                 getParentForChildren(),
@@ -1546,8 +1546,8 @@ private void ensureOptionsIsMutable() {
        }
     }
 
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> optionsBuilder_;
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder> optionsBuilder_;
 
     /**
      * 
@@ -1834,12 +1834,12 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
          getOptionsBuilderList() {
       return getOptionsFieldBuilder().getBuilderList();
     }
-    private com.google.protobuf.RepeatedFieldBuilderV3<
-        com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder> 
+    private RepeatedFieldBuilderV3Internal<
+            Option, Option.Builder, OptionOrBuilder>
         getOptionsFieldBuilder() {
       if (optionsBuilder_ == null) {
-        optionsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
-            com.google.protobuf.Option, com.google.protobuf.Option.Builder, com.google.protobuf.OptionOrBuilder>(
+        optionsBuilder_ = new RepeatedFieldBuilderV3Internal<
+                    Option, Option.Builder, OptionOrBuilder>(
                 options_,
                 ((bitField0_ & 0x00000008) != 0),
                 getParentForChildren(),
@@ -1850,8 +1850,8 @@ public com.google.protobuf.Option.Builder addOptionsBuilder(
     }
 
     private com.google.protobuf.SourceContext sourceContext_;
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> sourceContextBuilder_;
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder> sourceContextBuilder_;
     /**
      * 
      * The source context.
@@ -1992,12 +1992,12 @@ public com.google.protobuf.SourceContextOrBuilder getSourceContextOrBuilder() {
      *
      * .google.protobuf.SourceContext source_context = 5;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            SourceContext, SourceContext.Builder, SourceContextOrBuilder>
         getSourceContextFieldBuilder() {
       if (sourceContextBuilder_ == null) {
-        sourceContextBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.SourceContext, com.google.protobuf.SourceContext.Builder, com.google.protobuf.SourceContextOrBuilder>(
+        sourceContextBuilder_ = new SingleFieldBuilderV3Internal<
+                    SourceContext, SourceContext.Builder, SourceContextOrBuilder>(
                 getSourceContext(),
                 getParentForChildren(),
                 isClean());
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/TypeOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/TypeOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/TypeOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/TypeOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/TypeProto.java b/protobuf-api/src/main/java/com/google/protobuf/TypeProto.java
similarity index 90%
rename from protobuf-sdk/src/main/java/com/google/protobuf/TypeProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/TypeProto.java
index 1cc1248..03a0e71 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/TypeProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/TypeProto.java
@@ -18,27 +18,27 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Type_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Type_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Field_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Field_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Enum_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Enum_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_EnumValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_EnumValue_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Option_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Option_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -101,31 +101,31 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_Type_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_Type_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Type_descriptor,
         new java.lang.String[] { "Name", "Fields", "Oneofs", "Options", "SourceContext", "Syntax", "Edition", });
     internal_static_google_protobuf_Field_descriptor =
       getDescriptor().getMessageTypes().get(1);
     internal_static_google_protobuf_Field_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Field_descriptor,
         new java.lang.String[] { "Kind", "Cardinality", "Number", "Name", "TypeUrl", "OneofIndex", "Packed", "Options", "JsonName", "DefaultValue", });
     internal_static_google_protobuf_Enum_descriptor =
       getDescriptor().getMessageTypes().get(2);
     internal_static_google_protobuf_Enum_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Enum_descriptor,
         new java.lang.String[] { "Name", "Enumvalue", "Options", "SourceContext", "Syntax", "Edition", });
     internal_static_google_protobuf_EnumValue_descriptor =
       getDescriptor().getMessageTypes().get(3);
     internal_static_google_protobuf_EnumValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_EnumValue_descriptor,
         new java.lang.String[] { "Name", "Number", "Options", });
     internal_static_google_protobuf_Option_descriptor =
       getDescriptor().getMessageTypes().get(4);
     internal_static_google_protobuf_Option_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Option_descriptor,
         new java.lang.String[] { "Name", "Value", });
     com.google.protobuf.AnyProto.getDescriptor();
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/UInt32Value.java b/protobuf-api/src/main/java/com/google/protobuf/UInt32Value.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/UInt32Value.java
rename to protobuf-api/src/main/java/com/google/protobuf/UInt32Value.java
index b8e69f0..496998a 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/UInt32Value.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/UInt32Value.java
@@ -14,12 +14,12 @@
  * Protobuf type {@code google.protobuf.UInt32Value}
  */
 public final class UInt32Value extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.UInt32Value)
     UInt32ValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use UInt32Value.newBuilder() to construct.
-  private UInt32Value(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private UInt32Value(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private UInt32Value() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.WrappersProto.internal_static_google_protobuf_UInt32Value_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -159,20 +159,20 @@ public static com.google.protobuf.UInt32Value parseFrom(
   }
   public static com.google.protobuf.UInt32Value parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.UInt32Value parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.UInt32Value parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -180,20 +180,20 @@ public static com.google.protobuf.UInt32Value parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.UInt32Value parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.UInt32Value parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -213,7 +213,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -227,7 +227,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.UInt32Value}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.UInt32Value)
       com.google.protobuf.UInt32ValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -236,7 +236,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.WrappersProto.internal_static_google_protobuf_UInt32Value_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -249,7 +249,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/UInt32ValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/UInt32ValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/UInt32ValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/UInt32ValueOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/UInt64Value.java b/protobuf-api/src/main/java/com/google/protobuf/UInt64Value.java
similarity index 94%
rename from protobuf-sdk/src/main/java/com/google/protobuf/UInt64Value.java
rename to protobuf-api/src/main/java/com/google/protobuf/UInt64Value.java
index eabc937..054b07c 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/UInt64Value.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/UInt64Value.java
@@ -14,12 +14,12 @@
  * Protobuf type {@code google.protobuf.UInt64Value}
  */
 public final class UInt64Value extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.UInt64Value)
     UInt64ValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use UInt64Value.newBuilder() to construct.
-  private UInt64Value(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private UInt64Value(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private UInt64Value() {
@@ -38,7 +38,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.WrappersProto.internal_static_google_protobuf_UInt64Value_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -160,20 +160,20 @@ public static com.google.protobuf.UInt64Value parseFrom(
   }
   public static com.google.protobuf.UInt64Value parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.UInt64Value parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.UInt64Value parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -181,20 +181,20 @@ public static com.google.protobuf.UInt64Value parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.UInt64Value parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.UInt64Value parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -214,7 +214,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -228,7 +228,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.UInt64Value}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.UInt64Value)
       com.google.protobuf.UInt64ValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -237,7 +237,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.WrappersProto.internal_static_google_protobuf_UInt64Value_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -250,7 +250,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/UInt64ValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/UInt64ValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/UInt64ValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/UInt64ValueOrBuilder.java
diff --git a/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSet.java b/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSet.java
index 10fd7a7..d87ad2b 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSet.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSet.java
@@ -7,7 +7,6 @@
 
 package com.google.protobuf;
 
-import com.google.protobuf.AbstractMessageLite.Builder.LimitedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -110,11 +109,11 @@ public void writeTo(CodedOutputStream output) throws IOException {
 
   /**
    * Converts the set to a string in protocol buffer text format. This is just a trivial wrapper
-   * around {@link TextFormat.Printer#printToString(UnknownFieldSet)}.
+   * around {@link TextFormatInternal.printer#printToString(UnknownFieldSet)}.
    */
   @Override
   public String toString() {
-    return TextFormat.printer().printToString(this);
+    return TextFormatInternal.printer().printToString(this);
   }
 
   /**
diff --git a/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSetLite.java b/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
index 36c9481..809ac95 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/UnknownFieldSetLite.java
@@ -20,7 +20,7 @@
  *
  * @author dweis@google.com (Daniel Weis)
  */
-public final class UnknownFieldSetLite {
+final class UnknownFieldSetLite {
 
   // Arbitrarily chosen.
   // TODO: Tune this number?
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/Value.java b/protobuf-api/src/main/java/com/google/protobuf/Value.java
similarity index 95%
rename from protobuf-sdk/src/main/java/com/google/protobuf/Value.java
rename to protobuf-api/src/main/java/com/google/protobuf/Value.java
index 97dab1a..c56accd 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/Value.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/Value.java
@@ -17,12 +17,12 @@
  * Protobuf type {@code google.protobuf.Value}
  */
 public final class Value extends
-    com.google.protobuf.GeneratedMessageV3 implements
+    com.google.protobuf.GeneratedMessageV3Internal implements
     // @@protoc_insertion_point(message_implements:google.protobuf.Value)
     ValueOrBuilder {
 private static final long serialVersionUID = 0L;
   // Use Value.newBuilder() to construct.
-  private Value(com.google.protobuf.GeneratedMessageV3.Builder builder) {
+  private Value(com.google.protobuf.GeneratedMessageV3Internal.Builder builder) {
     super(builder);
   }
   private Value() {
@@ -41,7 +41,7 @@ protected java.lang.Object newInstance(
   }
 
   @java.lang.Override
-  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+  protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internalGetFieldAccessorTable() {
     return com.google.protobuf.StructProto.internal_static_google_protobuf_Value_fieldAccessorTable
         .ensureFieldAccessorsInitialized(
@@ -53,7 +53,7 @@ protected java.lang.Object newInstance(
   private java.lang.Object kind_;
   public enum KindCase
       implements com.google.protobuf.Internal.EnumLite,
-          com.google.protobuf.AbstractMessage.InternalOneOfEnum {
+          com.google.protobuf.GeneratedMessageV3Internal.InternalOneOfEnum {
     NULL_VALUE(1),
     NUMBER_VALUE(2),
     STRING_VALUE(3),
@@ -371,7 +371,7 @@ public void writeTo(com.google.protobuf.CodedOutputStream output)
           2, (double)((java.lang.Double) kind_));
     }
     if (kindCase_ == 3) {
-      com.google.protobuf.GeneratedMessageV3.writeString(output, 3, kind_);
+      com.google.protobuf.GeneratedMessageV3Internal.writeString(output, 3, kind_);
     }
     if (kindCase_ == 4) {
       output.writeBool(
@@ -402,7 +402,7 @@ public int getSerializedSize() {
             2, (double)((java.lang.Double) kind_));
     }
     if (kindCase_ == 3) {
-      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, kind_);
+      size += com.google.protobuf.GeneratedMessageV3Internal.computeStringSize(3, kind_);
     }
     if (kindCase_ == 4) {
       size += com.google.protobuf.CodedOutputStream
@@ -542,20 +542,20 @@ public static com.google.protobuf.Value parseFrom(
   }
   public static com.google.protobuf.Value parseFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Value parseFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
   public static com.google.protobuf.Value parseDelimitedFrom(java.io.InputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input);
   }
 
@@ -563,20 +563,20 @@ public static com.google.protobuf.Value parseDelimitedFrom(
       java.io.InputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
   }
   public static com.google.protobuf.Value parseFrom(
       com.google.protobuf.CodedInputStream input)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input);
   }
   public static com.google.protobuf.Value parseFrom(
       com.google.protobuf.CodedInputStream input,
       com.google.protobuf.ExtensionRegistryLite extensionRegistry)
       throws java.io.IOException {
-    return com.google.protobuf.GeneratedMessageV3
+    return com.google.protobuf.GeneratedMessageV3Internal
         .parseWithIOException(PARSER, input, extensionRegistry);
   }
 
@@ -596,7 +596,7 @@ public Builder toBuilder() {
 
   @java.lang.Override
   protected Builder newBuilderForType(
-      com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+      com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
     Builder builder = new Builder(parent);
     return builder;
   }
@@ -613,7 +613,7 @@ protected Builder newBuilderForType(
    * Protobuf type {@code google.protobuf.Value}
    */
   public static final class Builder extends
-      com.google.protobuf.GeneratedMessageV3.Builder implements
+      com.google.protobuf.GeneratedMessageV3Internal.Builder implements
       // @@protoc_insertion_point(builder_implements:google.protobuf.Value)
       com.google.protobuf.ValueOrBuilder {
     public static final com.google.protobuf.Descriptors.Descriptor
@@ -622,7 +622,7 @@ public static final class Builder extends
     }
 
     @java.lang.Override
-    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    protected com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
         internalGetFieldAccessorTable() {
       return com.google.protobuf.StructProto.internal_static_google_protobuf_Value_fieldAccessorTable
           .ensureFieldAccessorsInitialized(
@@ -635,7 +635,7 @@ private Builder() {
     }
 
     private Builder(
-        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
+        com.google.protobuf.GeneratedMessageV3Internal.BuilderParent parent) {
       super(parent);
 
     }
@@ -1196,8 +1196,8 @@ public Builder clearBoolValue() {
       return this;
     }
 
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.Struct, com.google.protobuf.Struct.Builder, com.google.protobuf.StructOrBuilder> structValueBuilder_;
+    private SingleFieldBuilderV3Internal<
+            Struct, Struct.Builder, StructOrBuilder> structValueBuilder_;
     /**
      * 
      * Represents a structured value.
@@ -1355,15 +1355,15 @@ public com.google.protobuf.StructOrBuilder getStructValueOrBuilder() {
      *
      * .google.protobuf.Struct struct_value = 5;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.Struct, com.google.protobuf.Struct.Builder, com.google.protobuf.StructOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            Struct, Struct.Builder, StructOrBuilder>
         getStructValueFieldBuilder() {
       if (structValueBuilder_ == null) {
         if (!(kindCase_ == 5)) {
           kind_ = com.google.protobuf.Struct.getDefaultInstance();
         }
-        structValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.Struct, com.google.protobuf.Struct.Builder, com.google.protobuf.StructOrBuilder>(
+        structValueBuilder_ = new SingleFieldBuilderV3Internal<
+                    Struct, Struct.Builder, StructOrBuilder>(
                 (com.google.protobuf.Struct) kind_,
                 getParentForChildren(),
                 isClean());
@@ -1374,8 +1374,8 @@ public com.google.protobuf.StructOrBuilder getStructValueOrBuilder() {
       return structValueBuilder_;
     }
 
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder> listValueBuilder_;
+    private SingleFieldBuilderV3Internal<
+            ListValue, ListValue.Builder, ListValueOrBuilder> listValueBuilder_;
     /**
      * 
      * Represents a repeated `Value`.
@@ -1533,15 +1533,15 @@ public com.google.protobuf.ListValueOrBuilder getListValueOrBuilder() {
      *
      * .google.protobuf.ListValue list_value = 6;
      */
-    private com.google.protobuf.SingleFieldBuilderV3<
-        com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder> 
+    private SingleFieldBuilderV3Internal<
+            ListValue, ListValue.Builder, ListValueOrBuilder>
         getListValueFieldBuilder() {
       if (listValueBuilder_ == null) {
         if (!(kindCase_ == 6)) {
           kind_ = com.google.protobuf.ListValue.getDefaultInstance();
         }
-        listValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
-            com.google.protobuf.ListValue, com.google.protobuf.ListValue.Builder, com.google.protobuf.ListValueOrBuilder>(
+        listValueBuilder_ = new SingleFieldBuilderV3Internal<
+                    ListValue, ListValue.Builder, ListValueOrBuilder>(
                 (com.google.protobuf.ListValue) kind_,
                 getParentForChildren(),
                 isClean());
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/ValueOrBuilder.java b/protobuf-api/src/main/java/com/google/protobuf/ValueOrBuilder.java
similarity index 100%
rename from protobuf-sdk/src/main/java/com/google/protobuf/ValueOrBuilder.java
rename to protobuf-api/src/main/java/com/google/protobuf/ValueOrBuilder.java
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/WrappersProto.java b/protobuf-api/src/main/java/com/google/protobuf/WrappersProto.java
similarity index 83%
rename from protobuf-sdk/src/main/java/com/google/protobuf/WrappersProto.java
rename to protobuf-api/src/main/java/com/google/protobuf/WrappersProto.java
index a83a961..0feeeba 100644
--- a/protobuf-sdk/src/main/java/com/google/protobuf/WrappersProto.java
+++ b/protobuf-api/src/main/java/com/google/protobuf/WrappersProto.java
@@ -18,47 +18,47 @@ public static void registerAllExtensions(
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_DoubleValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_DoubleValue_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_FloatValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_FloatValue_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Int64Value_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Int64Value_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_UInt64Value_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_UInt64Value_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_Int32Value_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_Int32Value_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_UInt32Value_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_UInt32Value_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_BoolValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_BoolValue_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_StringValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_StringValue_fieldAccessorTable;
   static final com.google.protobuf.Descriptors.Descriptor
     internal_static_google_protobuf_BytesValue_descriptor;
   static final 
-    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
+    com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable
       internal_static_google_protobuf_BytesValue_fieldAccessorTable;
 
   public static com.google.protobuf.Descriptors.FileDescriptor
@@ -89,55 +89,55 @@ public static void registerAllExtensions(
     internal_static_google_protobuf_DoubleValue_descriptor =
       getDescriptor().getMessageTypes().get(0);
     internal_static_google_protobuf_DoubleValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_DoubleValue_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_FloatValue_descriptor =
       getDescriptor().getMessageTypes().get(1);
     internal_static_google_protobuf_FloatValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_FloatValue_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_Int64Value_descriptor =
       getDescriptor().getMessageTypes().get(2);
     internal_static_google_protobuf_Int64Value_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Int64Value_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_UInt64Value_descriptor =
       getDescriptor().getMessageTypes().get(3);
     internal_static_google_protobuf_UInt64Value_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_UInt64Value_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_Int32Value_descriptor =
       getDescriptor().getMessageTypes().get(4);
     internal_static_google_protobuf_Int32Value_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_Int32Value_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_UInt32Value_descriptor =
       getDescriptor().getMessageTypes().get(5);
     internal_static_google_protobuf_UInt32Value_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_UInt32Value_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_BoolValue_descriptor =
       getDescriptor().getMessageTypes().get(6);
     internal_static_google_protobuf_BoolValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_BoolValue_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_StringValue_descriptor =
       getDescriptor().getMessageTypes().get(7);
     internal_static_google_protobuf_StringValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_StringValue_descriptor,
         new java.lang.String[] { "Value", });
     internal_static_google_protobuf_BytesValue_descriptor =
       getDescriptor().getMessageTypes().get(8);
     internal_static_google_protobuf_BytesValue_fieldAccessorTable = new
-      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
+      com.google.protobuf.GeneratedMessageV3Internal.FieldAccessorTable(
         internal_static_google_protobuf_BytesValue_descriptor,
         new java.lang.String[] { "Value", });
   }
diff --git a/protobuf-api/src/main/java/com/google/protobuf/AbstractMessage.java b/protobuf-sdk/src/main/java/com/google/protobuf/AbstractMessage.java
similarity index 94%
rename from protobuf-api/src/main/java/com/google/protobuf/AbstractMessage.java
rename to protobuf-sdk/src/main/java/com/google/protobuf/AbstractMessage.java
index f383625..0d9651e 100644
--- a/protobuf-api/src/main/java/com/google/protobuf/AbstractMessage.java
+++ b/protobuf-sdk/src/main/java/com/google/protobuf/AbstractMessage.java
@@ -30,16 +30,11 @@ public abstract class AbstractMessage
     // TODO: Update GeneratedMessage to parameterize with MessageType and BuilderType.
     extends AbstractMessageLite implements Message {
 
-  @Override
-  public boolean isInitialized() {
-    return MessageReflection.isInitialized(this);
-  }
-
   /**
    * Interface for the parent of a Builder that allows the builder to communicate invalidations back
    * to the parent for use when using nested builders.
    */
-  protected interface BuilderParent {
+  protected interface BuilderParent extends Message.BuilderParent{
 
     /**
      * A builder becomes dirty whenever a field is modified -- including fields in nested builders
@@ -55,9 +50,9 @@ protected interface BuilderParent {
     void markDirty();
   }
 
-  /** Create a nested builder. */
-  protected Message.Builder newBuilderForType(BuilderParent parent) {
-    throw new UnsupportedOperationException("Nested builder is not supported for this type.");
+  @Override
+  public boolean isInitialized() {
+    return MessageReflection.isInitialized(this);
   }
 
   @Override
@@ -446,29 +441,6 @@ protected static UninitializedMessageException newUninitializedMessageException(
       return new UninitializedMessageException(MessageReflection.findMissingFields(message));
     }
 
-    /**
-     * Used to support nested builders and called to mark this builder as clean. Clean builders will
-     * propagate the {@link BuilderParent#markDirty()} event to their parent builders, while dirty
-     * builders will not, as their parents should be dirty already.
-     *
-     * 

NOTE: Implementations that don't support nested builders don't need to override this - * method. - */ - void markClean() { - throw new IllegalStateException("Should be overridden by subclasses."); - } - - /** - * Used to support nested builders and called when this nested builder is no longer used by its - * parent builder and should release the reference to its parent builder. - * - *

NOTE: Implementations that don't support nested builders don't need to override this - * method. - */ - void dispose() { - throw new IllegalStateException("Should be overridden by subclasses."); - } - // =============================================================== // The following definitions seem to be required in order to make javac // not produce weird errors like: diff --git a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessage.java b/protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessage.java similarity index 99% rename from protobuf-api/src/main/java/com/google/protobuf/GeneratedMessage.java rename to protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessage.java index d3ff341..bb4f8d6 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessage.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessage.java @@ -54,6 +54,11 @@ protected GeneratedMessage(Builder builder) { unknownFields = builder.getUnknownFields(); } + @Override + public boolean isGenerated() { + return true; + } + @Override public Parser getParserForType() { throw new UnsupportedOperationException("This is supposed to be overridden by subclasses."); @@ -326,7 +331,7 @@ protected interface BuilderParent extends AbstractMessage.BuilderParent {} protected abstract Message.Builder newBuilderForType(BuilderParent parent); @Override - protected Message.Builder newBuilderForType(final AbstractMessage.BuilderParent parent) { + public Message.Builder newBuilderForType(final Message.BuilderParent parent) { return newBuilderForType( new BuilderParent() { @Override @@ -359,7 +364,12 @@ protected Builder(BuilderParent builderParent) { } @Override - void dispose() { + public boolean isGenerated() { + return true; + } + + @Override + public void dispose() { builderParent = null; } @@ -375,7 +385,7 @@ protected void onBuilt() { * and therefore invalidations are needed. */ @Override - protected void markClean() { + public void markClean() { this.isClean = true; } @@ -2925,7 +2935,7 @@ public Message.Builder getRepeatedBuilder( * @return a SerializedForm of this message */ protected Object writeReplace() throws ObjectStreamException { - return new GeneratedMessageLite.SerializedForm(this); + return new SerializedForm(this); } /** diff --git a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3.java b/protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessageV3.java similarity index 99% rename from protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3.java rename to protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessageV3.java index 9c4980f..d2a99ae 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/GeneratedMessageV3.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/GeneratedMessageV3.java @@ -544,7 +544,7 @@ protected interface BuilderParent extends AbstractMessage.BuilderParent {} /** TODO: generated class should implement this directly */ @Override - protected Message.Builder newBuilderForType(final AbstractMessage.BuilderParent parent) { + public Message.Builder newBuilderForType(final Message.BuilderParent parent) { return newBuilderForType( new BuilderParent() { @Override @@ -589,7 +589,7 @@ protected Builder(BuilderParent builderParent) { } @Override - void dispose() { + public void dispose() { builderParent = null; } @@ -605,7 +605,7 @@ protected void onBuilt() { * and therefore invalidations are needed. */ @Override - protected void markClean() { + public void markClean() { this.isClean = true; } @@ -3251,7 +3251,7 @@ public Message.Builder getRepeatedBuilder( * @return a SerializedForm of this message */ protected Object writeReplace() throws ObjectStreamException { - return new GeneratedMessageLite.SerializedForm(this); + return new SerializedForm(this); } /** diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/JavaFeaturesProto.java b/protobuf-sdk/src/main/java/com/google/protobuf/JavaFeaturesProto.java index 3b79d74..e5b8ac2 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/JavaFeaturesProto.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/JavaFeaturesProto.java @@ -485,42 +485,36 @@ public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseFrom( } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + return parseWithIOException(PARSER, input); } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + return parseWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); + return parseDelimitedWithIOException(PARSER, input); } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseDelimitedFrom( java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); + return parseDelimitedWithIOException(PARSER, input, extensionRegistry); } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseFrom( com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); + return parseWithIOException(PARSER, input); } public static com.google.protobuf.JavaFeaturesProto.JavaFeatures parseFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); + return parseWithIOException(PARSER, input, extensionRegistry); } @java.lang.Override diff --git a/protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java b/protobuf-sdk/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java similarity index 97% rename from protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java rename to protobuf-sdk/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java index b36794f..e1dddbe 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java @@ -7,8 +7,6 @@ package com.google.protobuf; -import static com.google.protobuf.Internal.checkNotNull; - import java.util.AbstractList; import java.util.ArrayList; import java.util.Collection; @@ -37,13 +35,13 @@ * @author jonp@google.com (Jon Perlow) */ public class RepeatedFieldBuilderV3< - MType extends AbstractMessage, - BType extends AbstractMessage.Builder, + MType extends Message, + BType extends Message.Builder, IType extends MessageOrBuilder> - implements AbstractMessage.BuilderParent { + implements Message.BuilderParent { // Parent to send changes to. - private AbstractMessage.BuilderParent parent; + private Message.BuilderParent parent; // List of messages. Never null. It may be immutable, in which case // isMessagesListMutable will be false. See note below. @@ -71,7 +69,7 @@ public class RepeatedFieldBuilderV3< // was set directly for an index. // Indicates that we've built a message and so we are now obligated - // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + // to dispatch dirty invalidations. See Message.BuilderListener. private boolean isClean; // A view of this builder that exposes a List interface of messages. This is @@ -104,7 +102,7 @@ public class RepeatedFieldBuilderV3< public RepeatedFieldBuilderV3( List messages, boolean isMessagesListMutable, - AbstractMessage.BuilderParent parent, + Message.BuilderParent parent, boolean isClean) { this.messages = messages; this.isMessagesListMutable = isMessagesListMutable; @@ -367,6 +365,13 @@ public BType addBuilder(MType message) { return builder.getBuilder(); } + static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + /** * Inserts a new builder at the specified position in this list. Shifts the element currently at * that position (if any) and any subsequent elements to the right (adds one to their indices). @@ -551,8 +556,8 @@ private void incrementModCounts() { * @param the common interface for the message and the builder */ private static class MessageExternalList< - MType extends AbstractMessage, - BType extends AbstractMessage.Builder, + MType extends Message, + BType extends Message.Builder, IType extends MessageOrBuilder> extends AbstractList implements List, RandomAccess { @@ -585,8 +590,8 @@ void incrementModCount() { * @param the common interface for the message and the builder */ private static class BuilderExternalList< - MType extends AbstractMessage, - BType extends AbstractMessage.Builder, + MType extends Message, + BType extends Message.Builder, IType extends MessageOrBuilder> extends AbstractList implements List, RandomAccess { @@ -619,8 +624,8 @@ void incrementModCount() { * @param the common interface for the message and the builder */ private static class MessageOrBuilderExternalList< - MType extends AbstractMessage, - BType extends AbstractMessage.Builder, + MType extends Message, + BType extends Message.Builder, IType extends MessageOrBuilder> extends AbstractList implements List, RandomAccess { diff --git a/protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java b/protobuf-sdk/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java similarity index 93% rename from protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java rename to protobuf-sdk/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java index 0aff2b8..d8d2532 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java @@ -7,8 +7,6 @@ package com.google.protobuf; -import static com.google.protobuf.Internal.checkNotNull; - /** * {@code SingleFieldBuilderV3} implements a structure that a protocol message uses to hold a single * field of another protocol message. It supports the classical use case of setting an immutable @@ -30,13 +28,13 @@ * @author jonp@google.com (Jon Perlow) */ public class SingleFieldBuilderV3< - MType extends AbstractMessage, - BType extends AbstractMessage.Builder, + MType extends Message, + BType extends Message.Builder, IType extends MessageOrBuilder> - implements AbstractMessage.BuilderParent { + implements Message.BuilderParent { // Parent to send changes to. - private AbstractMessage.BuilderParent parent; + private Message.BuilderParent parent; // Invariant: one of builder or message fields must be non-null. @@ -50,15 +48,22 @@ public class SingleFieldBuilderV3< private MType message; // Indicates that we've built a message and so we are now obligated - // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + // to dispatch dirty invalidations. See Message.BuilderListener. private boolean isClean; - public SingleFieldBuilderV3(MType message, AbstractMessage.BuilderParent parent, boolean isClean) { + public SingleFieldBuilderV3(MType message, Message.BuilderParent parent, boolean isClean) { this.message = checkNotNull(message); this.parent = parent; this.isClean = isClean; } + static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + public void dispose() { // Null out parent so we stop sending it invalidations. parent = null; diff --git a/protobuf-api/src/main/java/com/google/protobuf/TextFormat.java b/protobuf-sdk/src/main/java/com/google/protobuf/TextFormat.java similarity index 88% rename from protobuf-api/src/main/java/com/google/protobuf/TextFormat.java rename to protobuf-sdk/src/main/java/com/google/protobuf/TextFormat.java index a49919e..e0bfdd2 100644 --- a/protobuf-api/src/main/java/com/google/protobuf/TextFormat.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/TextFormat.java @@ -24,6 +24,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import static com.google.protobuf.TextFormatInternal.*; + /** * Provide text parsing and formatting support for proto2 instances. The implementation largely * follows text_format.cc. @@ -2396,176 +2398,11 @@ public static String escapeBytes(byte[] input) { */ public static ByteString unescapeBytes(CharSequence charString) throws InvalidEscapeSequenceException { - // First convert the Java character sequence to UTF-8 bytes. - ByteString input = ByteString.copyFromUtf8(charString.toString()); - // Then unescape certain byte sequences introduced by ASCII '\\'. The valid - // escapes can all be expressed with ASCII characters, so it is safe to - // operate on bytes here. - // - // Unescaping the input byte array will result in a byte sequence that's no - // longer than the input. That's because each escape sequence is between - // two and four bytes long and stands for a single byte. - final byte[] result = new byte[input.size()]; - int pos = 0; - for (int i = 0; i < input.size(); i++) { - byte c = input.byteAt(i); - if (c == '\\') { - if (i + 1 < input.size()) { - ++i; - c = input.byteAt(i); - if (isOctal(c)) { - // Octal escape. - int code = digitValue(c); - if (i + 1 < input.size() && isOctal(input.byteAt(i + 1))) { - ++i; - code = code * 8 + digitValue(input.byteAt(i)); - } - if (i + 1 < input.size() && isOctal(input.byteAt(i + 1))) { - ++i; - code = code * 8 + digitValue(input.byteAt(i)); - } - // TODO: Check that 0 <= code && code <= 0xFF. - result[pos++] = (byte) code; - } else { - switch (c) { - case 'a': - result[pos++] = 0x07; - break; - case 'b': - result[pos++] = '\b'; - break; - case 'f': - result[pos++] = '\f'; - break; - case 'n': - result[pos++] = '\n'; - break; - case 'r': - result[pos++] = '\r'; - break; - case 't': - result[pos++] = '\t'; - break; - case 'v': - result[pos++] = 0x0b; - break; - case '\\': - result[pos++] = '\\'; - break; - case '\'': - result[pos++] = '\''; - break; - case '"': - result[pos++] = '\"'; - break; - case '?': - result[pos++] = '?'; - break; - - case 'x': - // hex escape - int code = 0; - if (i + 1 < input.size() && isHex(input.byteAt(i + 1))) { - ++i; - code = digitValue(input.byteAt(i)); - } else { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\x' with no digits"); - } - if (i + 1 < input.size() && isHex(input.byteAt(i + 1))) { - ++i; - code = code * 16 + digitValue(input.byteAt(i)); - } - result[pos++] = (byte) code; - break; - - case 'u': - // Unicode escape - ++i; - if (i + 3 < input.size() - && isHex(input.byteAt(i)) - && isHex(input.byteAt(i + 1)) - && isHex(input.byteAt(i + 2)) - && isHex(input.byteAt(i + 3))) { - char ch = - (char) - (digitValue(input.byteAt(i)) << 12 - | digitValue(input.byteAt(i + 1)) << 8 - | digitValue(input.byteAt(i + 2)) << 4 - | digitValue(input.byteAt(i + 3))); - - if (ch >= Character.MIN_SURROGATE && ch <= Character.MAX_SURROGATE) { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\u' refers to a surrogate"); - } - byte[] chUtf8 = Character.toString(ch).getBytes(Internal.UTF_8); - System.arraycopy(chUtf8, 0, result, pos, chUtf8.length); - pos += chUtf8.length; - i += 3; - } else { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\u' with too few hex chars"); - } - break; - - case 'U': - // Unicode escape - ++i; - if (i + 7 >= input.size()) { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\U' with too few hex chars"); - } - int codepoint = 0; - for (int offset = i; offset < i + 8; offset++) { - byte b = input.byteAt(offset); - if (!isHex(b)) { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\U' with too few hex chars"); - } - codepoint = (codepoint << 4) | digitValue(b); - } - if (!Character.isValidCodePoint(codepoint)) { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\U" - + input.substring(i, i + 8).toStringUtf8() - + "' is not a valid code point value"); - } - Character.UnicodeBlock unicodeBlock = Character.UnicodeBlock.of(codepoint); - if (unicodeBlock != null - && (unicodeBlock.equals(Character.UnicodeBlock.LOW_SURROGATES) - || unicodeBlock.equals(Character.UnicodeBlock.HIGH_SURROGATES) - || unicodeBlock.equals( - Character.UnicodeBlock.HIGH_PRIVATE_USE_SURROGATES))) { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\U" - + input.substring(i, i + 8).toStringUtf8() - + "' refers to a surrogate code unit"); - } - int[] codepoints = new int[1]; - codepoints[0] = codepoint; - byte[] chUtf8 = new String(codepoints, 0, 1).getBytes(Internal.UTF_8); - System.arraycopy(chUtf8, 0, result, pos, chUtf8.length); - pos += chUtf8.length; - i += 7; - break; - - default: - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\" + (char) c + '\''); - } - } - } else { - throw new InvalidEscapeSequenceException( - "Invalid escape sequence: '\\' at end of string."); - } - } else { - result[pos++] = c; + try { + return TextFormatEscaper.unescapeBytes(charString); + } catch (TextFormatEscaper.InvalidEscapeSequenceException e) { + throw new TextFormat.InvalidEscapeSequenceException(e.getMessage()); } - } - - return result.length == pos - ? ByteString.wrap(result) // This reference has not been out of our control. - : ByteString.copyFrom(result, 0, pos); } /** @@ -2625,128 +2462,4 @@ private static int digitValue(final byte c) { return c - 'A' + 10; } } - - /** - * Parse a 32-bit signed integer from the text. Unlike the Java standard {@code - * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal - * and octal numbers, respectively. - */ - static int parseInt32(final String text) throws NumberFormatException { - return (int) parseInteger(text, true, false); - } - - /** - * Parse a 32-bit unsigned integer from the text. Unlike the Java standard {@code - * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal - * and octal numbers, respectively. The result is coerced to a (signed) {@code int} when returned - * since Java has no unsigned integer type. - */ - static int parseUInt32(final String text) throws NumberFormatException { - return (int) parseInteger(text, false, false); - } - - /** - * Parse a 64-bit signed integer from the text. Unlike the Java standard {@code - * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal - * and octal numbers, respectively. - */ - static long parseInt64(final String text) throws NumberFormatException { - return parseInteger(text, true, true); - } - - /** - * Parse a 64-bit unsigned integer from the text. Unlike the Java standard {@code - * Integer.parseInt()}, this function recognizes the prefixes "0x" and "0" to signify hexadecimal - * and octal numbers, respectively. The result is coerced to a (signed) {@code long} when returned - * since Java has no unsigned long type. - */ - static long parseUInt64(final String text) throws NumberFormatException { - return parseInteger(text, false, true); - } - - private static long parseInteger(final String text, final boolean isSigned, final boolean isLong) - throws NumberFormatException { - int pos = 0; - - boolean negative = false; - if (text.startsWith("-", pos)) { - if (!isSigned) { - throw new NumberFormatException("Number must be positive: " + text); - } - ++pos; - negative = true; - } - - int radix = 10; - if (text.startsWith("0x", pos)) { - pos += 2; - radix = 16; - } else if (text.startsWith("0", pos)) { - radix = 8; - } - - final String numberText = text.substring(pos); - - long result = 0; - if (numberText.length() < 16) { - // Can safely assume no overflow. - result = Long.parseLong(numberText, radix); - if (negative) { - result = -result; - } - - // Check bounds. - // No need to check for 64-bit numbers since they'd have to be 16 chars - // or longer to overflow. - if (!isLong) { - if (isSigned) { - if (result > Integer.MAX_VALUE || result < Integer.MIN_VALUE) { - throw new NumberFormatException( - "Number out of range for 32-bit signed integer: " + text); - } - } else { - if (result >= (1L << 32) || result < 0) { - throw new NumberFormatException( - "Number out of range for 32-bit unsigned integer: " + text); - } - } - } - } else { - BigInteger bigValue = new BigInteger(numberText, radix); - if (negative) { - bigValue = bigValue.negate(); - } - - // Check bounds. - if (!isLong) { - if (isSigned) { - if (bigValue.bitLength() > 31) { - throw new NumberFormatException( - "Number out of range for 32-bit signed integer: " + text); - } - } else { - if (bigValue.bitLength() > 32) { - throw new NumberFormatException( - "Number out of range for 32-bit unsigned integer: " + text); - } - } - } else { - if (isSigned) { - if (bigValue.bitLength() > 63) { - throw new NumberFormatException( - "Number out of range for 64-bit signed integer: " + text); - } - } else { - if (bigValue.bitLength() > 64) { - throw new NumberFormatException( - "Number out of range for 64-bit unsigned integer: " + text); - } - } - } - - result = bigValue.longValue(); - } - - return result; - } } diff --git a/protobuf-api/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java b/protobuf-sdk/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java similarity index 100% rename from protobuf-api/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java rename to protobuf-sdk/src/main/java/com/google/protobuf/TextFormatParseInfoTree.java diff --git a/protobuf-api/src/main/java/com/google/protobuf/TextFormatParseLocation.java b/protobuf-sdk/src/main/java/com/google/protobuf/TextFormatParseLocation.java similarity index 100% rename from protobuf-api/src/main/java/com/google/protobuf/TextFormatParseLocation.java rename to protobuf-sdk/src/main/java/com/google/protobuf/TextFormatParseLocation.java diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/compiler/PluginProtos.java b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/PluginProtos.java index 501218a..6f80eff 100644 --- a/protobuf-sdk/src/main/java/com/google/protobuf/compiler/PluginProtos.java +++ b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/PluginProtos.java @@ -4,6 +4,8 @@ // Protobuf Java Version: 3.25.5 package com.google.protobuf.compiler; +import java.util.Map; + public final class PluginProtos { private PluginProtos() {} public static void registerAllExtensions( @@ -2392,7 +2394,7 @@ public Builder addFileToGenerate( public Builder addAllFileToGenerate( java.lang.Iterable values) { ensureFileToGenerateIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( + com.google.protobuf.Internal.addAll( values, fileToGenerate_); bitField0_ |= 0x00000001; onChanged(); @@ -2549,7 +2551,7 @@ private void ensureProtoFileIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< + private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> protoFileBuilder_; /** @@ -2901,7 +2903,7 @@ public Builder addAllProtoFile( java.lang.Iterable values) { if (protoFileBuilder_ == null) { ensureProtoFileIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( + com.google.protobuf.Internal.addAll( values, protoFile_); onChanged(); } else { @@ -3161,11 +3163,11 @@ public com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder addProto getProtoFileBuilderList() { return getProtoFileFieldBuilder().getBuilderList(); } - private com.google.protobuf.RepeatedFieldBuilderV3< + private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> getProtoFileFieldBuilder() { if (protoFileBuilder_ == null) { - protoFileBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + protoFileBuilder_ = new com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder>( protoFile_, ((bitField0_ & 0x00000004) != 0), @@ -3185,7 +3187,7 @@ private void ensureSourceFileDescriptorsIsMutable() { } } - private com.google.protobuf.RepeatedFieldBuilderV3< + private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> sourceFileDescriptorsBuilder_; /** @@ -3377,7 +3379,7 @@ public Builder addAllSourceFileDescriptors( java.lang.Iterable values) { if (sourceFileDescriptorsBuilder_ == null) { ensureSourceFileDescriptorsIsMutable(); - com.google.protobuf.AbstractMessageLite.Builder.addAll( + com.google.protobuf.Internal.addAll( values, sourceFileDescriptors_); onChanged(); } else { @@ -3509,11 +3511,11 @@ public com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder addSourc getSourceFileDescriptorsBuilderList() { return getSourceFileDescriptorsFieldBuilder().getBuilderList(); } - private com.google.protobuf.RepeatedFieldBuilderV3< + private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder> getSourceFileDescriptorsFieldBuilder() { if (sourceFileDescriptorsBuilder_ == null) { - sourceFileDescriptorsBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3< + sourceFileDescriptorsBuilder_ = new com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal< com.google.protobuf.DescriptorProtos.FileDescriptorProto, com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder, com.google.protobuf.DescriptorProtos.FileDescriptorProtoOrBuilder>( sourceFileDescriptors_, ((bitField0_ & 0x00000008) != 0), @@ -3525,7 +3527,7 @@ public com.google.protobuf.DescriptorProtos.FileDescriptorProto.Builder addSourc } private com.google.protobuf.compiler.PluginProtos.Version compilerVersion_; - private com.google.protobuf.SingleFieldBuilderV3< + private com.google.protobuf.compiler.SingleFieldBuilderV3Internal< com.google.protobuf.compiler.PluginProtos.Version, com.google.protobuf.compiler.PluginProtos.Version.Builder, com.google.protobuf.compiler.PluginProtos.VersionOrBuilder> compilerVersionBuilder_; /** *

@@ -3667,11 +3669,11 @@ public com.google.protobuf.compiler.PluginProtos.VersionOrBuilder getCompilerVer
        *
        * optional .google.protobuf.compiler.Version compiler_version = 3;
        */
-      private com.google.protobuf.SingleFieldBuilderV3<
+      private com.google.protobuf.compiler.SingleFieldBuilderV3Internal<
           com.google.protobuf.compiler.PluginProtos.Version, com.google.protobuf.compiler.PluginProtos.Version.Builder, com.google.protobuf.compiler.PluginProtos.VersionOrBuilder> 
           getCompilerVersionFieldBuilder() {
         if (compilerVersionBuilder_ == null) {
-          compilerVersionBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
+          compilerVersionBuilder_ = new com.google.protobuf.compiler.SingleFieldBuilderV3Internal<
               com.google.protobuf.compiler.PluginProtos.Version, com.google.protobuf.compiler.PluginProtos.Version.Builder, com.google.protobuf.compiler.PluginProtos.VersionOrBuilder>(
                   getCompilerVersion(),
                   getParentForChildren(),
@@ -5743,7 +5745,7 @@ public Builder setContentBytes(
         }
 
         private com.google.protobuf.DescriptorProtos.GeneratedCodeInfo generatedCodeInfo_;
-        private com.google.protobuf.SingleFieldBuilderV3<
+        private com.google.protobuf.compiler.SingleFieldBuilderV3Internal<
             com.google.protobuf.DescriptorProtos.GeneratedCodeInfo, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfoOrBuilder> generatedCodeInfoBuilder_;
         /**
          * 
@@ -5903,11 +5905,11 @@ public com.google.protobuf.DescriptorProtos.GeneratedCodeInfoOrBuilder getGenera
          *
          * optional .google.protobuf.GeneratedCodeInfo generated_code_info = 16;
          */
-        private com.google.protobuf.SingleFieldBuilderV3<
+        private com.google.protobuf.compiler.SingleFieldBuilderV3Internal<
             com.google.protobuf.DescriptorProtos.GeneratedCodeInfo, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfoOrBuilder> 
             getGeneratedCodeInfoFieldBuilder() {
           if (generatedCodeInfoBuilder_ == null) {
-            generatedCodeInfoBuilder_ = new com.google.protobuf.SingleFieldBuilderV3<
+            generatedCodeInfoBuilder_ = new com.google.protobuf.compiler.SingleFieldBuilderV3Internal<
                 com.google.protobuf.DescriptorProtos.GeneratedCodeInfo, com.google.protobuf.DescriptorProtos.GeneratedCodeInfo.Builder, com.google.protobuf.DescriptorProtos.GeneratedCodeInfoOrBuilder>(
                     getGeneratedCodeInfo(),
                     getParentForChildren(),
@@ -7048,7 +7050,7 @@ private void ensureFileIsMutable() {
          }
       }
 
-      private com.google.protobuf.RepeatedFieldBuilderV3<
+      private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal<
           com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File.Builder, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FileOrBuilder> fileBuilder_;
 
       /**
@@ -7180,7 +7182,7 @@ public Builder addAllFile(
           java.lang.Iterable values) {
         if (fileBuilder_ == null) {
           ensureFileIsMutable();
-          com.google.protobuf.AbstractMessageLite.Builder.addAll(
+          com.google.protobuf.Internal.addAll(
               values, file_);
           onChanged();
         } else {
@@ -7264,11 +7266,11 @@ public com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File.Buil
            getFileBuilderList() {
         return getFileFieldBuilder().getBuilderList();
       }
-      private com.google.protobuf.RepeatedFieldBuilderV3<
+      private com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal<
           com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File.Builder, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FileOrBuilder> 
           getFileFieldBuilder() {
         if (fileBuilder_ == null) {
-          fileBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
+          fileBuilder_ = new com.google.protobuf.compiler.RepeatedFieldBuilderV3Internal<
               com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.File.Builder, com.google.protobuf.compiler.PluginProtos.CodeGeneratorResponse.FileOrBuilder>(
                   file_,
                   ((bitField0_ & 0x00000010) != 0),
diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/compiler/RepeatedFieldBuilderV3Internal.java b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/RepeatedFieldBuilderV3Internal.java
new file mode 100644
index 0000000..3390aa9
--- /dev/null
+++ b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/RepeatedFieldBuilderV3Internal.java
@@ -0,0 +1,656 @@
+// Protocol Buffers - Google's data interchange format
+// Copyright 2008 Google Inc.  All rights reserved.
+//
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file or at
+// https://developers.google.com/open-source/licenses/bsd
+
+package com.google.protobuf.compiler;
+
+import com.google.protobuf.Message;
+import com.google.protobuf.MessageOrBuilder;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.RandomAccess;
+
+
+/**
+ * {@code RepeatedFieldBuilderV3} implements a structure that a protocol message uses to hold a
+ * repeated field of other protocol messages. It supports the classical use case of adding immutable
+ * {@link Message}'s to the repeated field and is highly optimized around this (no extra memory
+ * allocations and sharing of immutable arrays). 
+ * It also supports the additional use case of adding a {@link Message.Builder} to the repeated + * field and deferring conversion of that {@code Builder} to an immutable {@code Message}. In this + * way, it's possible to maintain a tree of {@code Builder}'s that acts as a fully read/write data + * structure.
+ * Logically, one can think of a tree of builders as converting the entire tree to messages when + * build is called on the root or when any method is called that desires a Message instead of a + * Builder. In terms of the implementation, the {@code SingleFieldBuilderV3} and {@code + * RepeatedFieldBuilderV3} classes cache messages that were created so that messages only need to be + * created when some change occurred in its builder or a builder for one of its descendants. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + * @author jonp@google.com (Jon Perlow) + */ +class RepeatedFieldBuilderV3Internal< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + implements Message.BuilderParent { + + // Parent to send changes to. + private Message.BuilderParent parent; + + // List of messages. Never null. It may be immutable, in which case + // isMessagesListMutable will be false. See note below. + private List messages; + + // Whether messages is an mutable array that can be modified. + private boolean isMessagesListMutable; + + // List of builders. May be null, in which case, no nested builders were + // created. If not null, entries represent the builder for that index. + private List> builders; + + // Here are the invariants for messages and builders: + // 1. messages is never null and its count corresponds to the number of items + // in the repeated field. + // 2. If builders is non-null, messages and builders MUST always + // contain the same number of items. + // 3. Entries in either array can be null, but for any index, there MUST be + // either a Message in messages or a builder in builders. + // 4. If the builder at an index is non-null, the builder is + // authoritative. This is the case where a Builder was set on the index. + // Any message in the messages array MUST be ignored. + // t. If the builder at an index is null, the message in the messages + // list is authoritative. This is the case where a Message (not a Builder) + // was set directly for an index. + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + private boolean isClean; + + // A view of this builder that exposes a List interface of messages. This is + // initialized on demand. This is fully backed by this object and all changes + // are reflected in it. Access to any item converts it to a message if it + // was a builder. + private MessageExternalList externalMessageList; + + // A view of this builder that exposes a List interface of builders. This is + // initialized on demand. This is fully backed by this object and all changes + // are reflected in it. Access to any item converts it to a builder if it + // was a message. + private BuilderExternalList externalBuilderList; + + // A view of this builder that exposes a List interface of the interface + // implemented by messages and builders. This is initialized on demand. This + // is fully backed by this object and all changes are reflected in it. + // Access to any item returns either a builder or message depending on + // what is most efficient. + private MessageOrBuilderExternalList externalMessageOrBuilderList; + + /** + * Constructs a new builder with an empty list of messages. + * + * @param messages the current list of messages + * @param isMessagesListMutable Whether the messages list is mutable + * @param parent a listener to notify of changes + * @param isClean whether the builder is initially marked clean + */ + public RepeatedFieldBuilderV3Internal( + List messages, + boolean isMessagesListMutable, + Message.BuilderParent parent, + boolean isClean) { + this.messages = messages; + this.isMessagesListMutable = isMessagesListMutable; + this.parent = parent; + this.isClean = isClean; + } + + public void dispose() { + // Null out parent so we stop sending it invalidations. + parent = null; + } + + /** + * Ensures that the list of messages is mutable so it can be updated. If it's immutable, a copy is + * made. + */ + private void ensureMutableMessageList() { + if (!isMessagesListMutable) { + messages = new ArrayList(messages); + isMessagesListMutable = true; + } + } + + /** + * Ensures that the list of builders is not null. If it's null, the list is created and + * initialized to be the same size as the messages list with null entries. + */ + private void ensureBuilders() { + if (this.builders == null) { + this.builders = new ArrayList>(messages.size()); + for (int i = 0; i < messages.size(); i++) { + builders.add(null); + } + } + } + + /** + * Gets the count of items in the list. + * + * @return the count of items in the list. + */ + public int getCount() { + return messages.size(); + } + + /** + * Gets whether the list is empty. + * + * @return whether the list is empty + */ + public boolean isEmpty() { + return messages.isEmpty(); + } + + /** + * Get the message at the specified index. If the message is currently stored as a {@code + * Builder}, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} + * on it. + * + * @param index the index of the message to get + * @return the message for the specified index + */ + public MType getMessage(int index) { + return getMessage(index, false); + } + + /** + * Get the message at the specified index. If the message is currently stored as a {@code + * Builder}, it is converted to a {@code Message} by calling {@link Message.Builder#buildPartial} + * on it. + * + * @param index the index of the message to get + * @param forBuild this is being called for build so we want to make sure we + * SingleFieldBuilderV3.build to send dirty invalidations + * @return the message for the specified index + */ + private MType getMessage(int index, boolean forBuild) { + if (this.builders == null) { + // We don't have any builders -- return the current Message. + // This is the case where no builder was created, so we MUST have a + // Message. + return messages.get(index); + } + + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + // We don't have a builder -- return the current message. + // This is the case where no builder was created for the entry at index, + // so we MUST have a message. + return messages.get(index); + + } else { + return forBuild ? builder.build() : builder.getMessage(); + } + } + + /** + * Gets a builder for the specified index. If no builder has been created for that index, a + * builder is created on demand by calling {@link Message#toBuilder}. + * + * @param index the index of the message to get + * @return The builder for that index + */ + public BType getBuilder(int index) { + ensureBuilders(); + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + MType message = messages.get(index); + builder = new SingleFieldBuilderV3Internal(message, this, isClean); + builders.set(index, builder); + } + return builder.getBuilder(); + } + + /** + * Gets the base class interface for the specified index. This may either be a builder or a + * message. It will return whatever is more efficient. + * + * @param index the index of the message to get + * @return the message or builder for the index as the base class interface + */ + @SuppressWarnings("unchecked") + public IType getMessageOrBuilder(int index) { + if (this.builders == null) { + // We don't have any builders -- return the current Message. + // This is the case where no builder was created, so we MUST have a + // Message. + return (IType) messages.get(index); + } + + SingleFieldBuilderV3Internal builder = builders.get(index); + if (builder == null) { + // We don't have a builder -- return the current message. + // This is the case where no builder was created for the entry at index, + // so we MUST have a message. + return (IType) messages.get(index); + + } else { + return builder.getMessageOrBuilder(); + } + } + + static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + + /** + * Sets a message at the specified index replacing the existing item at that index. + * + * @param index the index to set. + * @param message the message to set + * @return the builder + */ +// @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal setMessage(int index, MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.set(index, message); + if (builders != null) { + SingleFieldBuilderV3Internal entry = builders.set(index, null); + if (entry != null) { + entry.dispose(); + } + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends the specified element to the end of this list. + * + * @param message the message to add + * @return the builder + */ +// @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addMessage(MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.add(message); + if (builders != null) { + builders.add(null); + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Inserts the specified message at the specified position in this list. Shifts the element + * currently at that position (if any) and any subsequent elements to the right (adds one to their + * indices). + * + * @param index the index at which to insert the message + * @param message the message to add + * @return the builder + */ +// @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addMessage(int index, MType message) { + checkNotNull(message); + ensureMutableMessageList(); + messages.add(index, message); + if (builders != null) { + builders.add(index, null); + } + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends all of the messages in the specified collection to the end of this list, in the order + * that they are returned by the specified collection's iterator. + * + * @param values the messages to add + * @return the builder + */ +// @CanIgnoreReturnValue + public RepeatedFieldBuilderV3Internal addAllMessages( + Iterable values) { + for (final MType value : values) { + checkNotNull(value); + } + + // If we can inspect the size, we can more efficiently add messages. + int size = -1; + if (values instanceof Collection) { + final Collection collection = (Collection) values; + if (collection.isEmpty()) { + return this; + } + size = collection.size(); + } + ensureMutableMessageList(); + + if (size >= 0 && messages instanceof ArrayList) { + ((ArrayList) messages).ensureCapacity(messages.size() + size); + } + + for (MType value : values) { + addMessage(value); + } + + onChanged(); + incrementModCounts(); + return this; + } + + /** + * Appends a new builder to the end of this list and returns the builder. + * + * @param message the message to add which is the basis of the builder + * @return the new builder + */ + public BType addBuilder(MType message) { + ensureMutableMessageList(); + ensureBuilders(); + SingleFieldBuilderV3Internal builder = + new SingleFieldBuilderV3Internal(message, this, isClean); + messages.add(null); + builders.add(builder); + onChanged(); + incrementModCounts(); + return builder.getBuilder(); + } + + /** + * Inserts a new builder at the specified position in this list. Shifts the element currently at + * that position (if any) and any subsequent elements to the right (adds one to their indices). + * + * @param index the index at which to insert the builder + * @param message the message to add which is the basis of the builder + * @return the builder + */ + public BType addBuilder(int index, MType message) { + ensureMutableMessageList(); + ensureBuilders(); + SingleFieldBuilderV3Internal builder = + new SingleFieldBuilderV3Internal(message, this, isClean); + messages.add(index, null); + builders.add(index, builder); + onChanged(); + incrementModCounts(); + return builder.getBuilder(); + } + + /** + * Removes the element at the specified position in this list. Shifts any subsequent elements to + * the left (subtracts one from their indices). + * + * @param index the index at which to remove the message + */ + public void remove(int index) { + ensureMutableMessageList(); + messages.remove(index); + if (builders != null) { + SingleFieldBuilderV3Internal entry = builders.remove(index); + if (entry != null) { + entry.dispose(); + } + } + onChanged(); + incrementModCounts(); + } + + /** Removes all of the elements from this list. The list will be empty after this call returns. */ + public void clear() { + messages = Collections.emptyList(); + isMessagesListMutable = false; + if (builders != null) { + for (SingleFieldBuilderV3Internal entry : builders) { + if (entry != null) { + entry.dispose(); + } + } + builders = null; + } + onChanged(); + incrementModCounts(); + } + + /** + * Builds the list of messages from the builder and returns them. + * + * @return an immutable list of messages + */ + public List build() { + // Now that build has been called, we are required to dispatch + // invalidations. + isClean = true; + + if (!isMessagesListMutable && builders == null) { + // We still have an immutable list and we never created a builder. + return messages; + } + + boolean allMessagesInSync = true; + if (!isMessagesListMutable) { + // We still have an immutable list. Let's see if any of them are out + // of sync with their builders. + for (int i = 0; i < messages.size(); i++) { + Message message = messages.get(i); + SingleFieldBuilderV3Internal builder = builders.get(i); + if (builder != null) { + if (builder.build() != message) { + allMessagesInSync = false; + break; + } + } + } + if (allMessagesInSync) { + // Immutable list is still in sync. + return messages; + } + } + + // Need to make sure messages is up to date + ensureMutableMessageList(); + for (int i = 0; i < messages.size(); i++) { + messages.set(i, getMessage(i, true)); + } + + // We're going to return our list as immutable so we mark that we can + // no longer update it. + messages = Collections.unmodifiableList(messages); + isMessagesListMutable = false; + return messages; + } + + /** + * Gets a view of the builder as a list of messages. The returned list is live and will reflect + * any changes to the underlying builder. + * + * @return the messages in the list + */ + public List getMessageList() { + if (externalMessageList == null) { + externalMessageList = new MessageExternalList(this); + } + return externalMessageList; + } + + /** + * Gets a view of the builder as a list of builders. This returned list is live and will reflect + * any changes to the underlying builder. + * + * @return the builders in the list + */ + public List getBuilderList() { + if (externalBuilderList == null) { + externalBuilderList = new BuilderExternalList(this); + } + return externalBuilderList; + } + + /** + * Gets a view of the builder as a list of MessageOrBuilders. This returned list is live and will + * reflect any changes to the underlying builder. + * + * @return the builders in the list + */ + public List getMessageOrBuilderList() { + if (externalMessageOrBuilderList == null) { + externalMessageOrBuilderList = new MessageOrBuilderExternalList(this); + } + return externalMessageOrBuilderList; + } + + /** + * Called when a the builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + private void onChanged() { + if (isClean && parent != null) { + parent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + @Override + public void markDirty() { + onChanged(); + } + + /** + * Increments the mod counts so that an ConcurrentModificationException can be thrown if calling + * code tries to modify the builder while its iterating the list. + */ + private void incrementModCounts() { + if (externalMessageList != null) { + externalMessageList.incrementModCount(); + } + if (externalBuilderList != null) { + externalBuilderList.incrementModCount(); + } + if (externalMessageOrBuilderList != null) { + externalMessageOrBuilderList.incrementModCount(); + } + } + + /** + * Provides a live view of the builder as a list of messages. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class MessageExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + MessageExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public MType get(int index) { + return builder.getMessage(index); + } + + void incrementModCount() { + modCount++; + } + } + + /** + * Provides a live view of the builder as a list of builders. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class BuilderExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + BuilderExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public BType get(int index) { + return builder.getBuilder(index); + } + + void incrementModCount() { + modCount++; + } + } + + /** + * Provides a live view of the builder as a list of builders. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + */ + private static class MessageOrBuilderExternalList< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + extends AbstractList implements List, RandomAccess { + + RepeatedFieldBuilderV3Internal builder; + + MessageOrBuilderExternalList(RepeatedFieldBuilderV3Internal builder) { + this.builder = builder; + } + + @Override + public int size() { + return this.builder.getCount(); + } + + @Override + public IType get(int index) { + return builder.getMessageOrBuilder(index); + } + + void incrementModCount() { + modCount++; + } + } +} diff --git a/protobuf-sdk/src/main/java/com/google/protobuf/compiler/SingleFieldBuilderV3Internal.java b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/SingleFieldBuilderV3Internal.java new file mode 100644 index 0000000..da0cd92 --- /dev/null +++ b/protobuf-sdk/src/main/java/com/google/protobuf/compiler/SingleFieldBuilderV3Internal.java @@ -0,0 +1,219 @@ +// Protocol Buffers - Google's data interchange format +// Copyright 2008 Google Inc. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file or at +// https://developers.google.com/open-source/licenses/bsd + +package com.google.protobuf.compiler; + +import com.google.protobuf.Message; +import com.google.protobuf.MessageOrBuilder; + +/** + * {@code SingleFieldBuilderV3} implements a structure that a protocol message uses to hold a single + * field of another protocol message. It supports the classical use case of setting an immutable + * {@link Message} as the value of the field and is highly optimized around this. + * + *

It also supports the additional use case of setting a {@link Message.Builder} as the field and + * deferring conversion of that {@code Builder} to an immutable {@code Message}. In this way, it's + * possible to maintain a tree of {@code Builder}'s that acts as a fully read/write data structure. + *
+ * Logically, one can think of a tree of builders as converting the entire tree to messages when + * build is called on the root or when any method is called that desires a Message instead of a + * Builder. In terms of the implementation, the {@code SingleFieldBuilderV3} and {@code + * RepeatedFieldBuilderV3} classes cache messages that were created so that messages only need to be + * created when some change occurred in its builder or a builder for one of its descendants. + * + * @param the type of message for the field + * @param the type of builder for the field + * @param the common interface for the message and the builder + * @author jonp@google.com (Jon Perlow) + */ +class SingleFieldBuilderV3Internal< + MType extends Message, + BType extends Message.Builder, + IType extends MessageOrBuilder> + implements Message.BuilderParent { + + // Parent to send changes to. + private Message.BuilderParent parent; + + // Invariant: one of builder or message fields must be non-null. + + // If set, this is the case where we are backed by a builder. In this case, + // message field represents a cached message for the builder (or null if + // there is no cached message). + private BType builder; + + // If builder is non-null, this represents a cached message from the builder. + // If builder is null, this is the authoritative message for the field. + private MType message; + + // Indicates that we've built a message and so we are now obligated + // to dispatch dirty invalidations. See AbstractMessage.BuilderListener. + private boolean isClean; + + public SingleFieldBuilderV3Internal(MType message, Message.BuilderParent parent, boolean isClean) { + this.message = checkNotNull(message); + this.parent = parent; + this.isClean = isClean; + } + + public void dispose() { + // Null out parent so we stop sending it invalidations. + parent = null; + } + + /** + * Get the message for the field. If the message is currently stored as a {@code Builder}, it is + * converted to a {@code Message} by calling {@link Message.Builder#buildPartial} on it. If no + * message has been set, returns the default instance of the message. + * + * @return the message for the field + */ + @SuppressWarnings("unchecked") + public MType getMessage() { + if (message == null) { + // If message is null, the invariant is that we must be have a builder. + message = (MType) builder.buildPartial(); + } + return message; + } + + /** + * Builds the message and returns it. + * + * @return the message + */ + public MType build() { + // Now that build has been called, we are required to dispatch + // invalidations. + isClean = true; + return getMessage(); + } + + /** + * Gets a builder for the field. If no builder has been created yet, a builder is created on + * demand by calling {@link Message#toBuilder}. + * + * @return The builder for the field + */ + @SuppressWarnings("unchecked") + public BType getBuilder() { + if (builder == null) { + // builder.mergeFrom() on a fresh builder + // does not create any sub-objects with independent clean/dirty states, + // therefore setting the builder itself to clean without actually calling + // build() cannot break any invariants. + builder = (BType) message.newBuilderForType(); + builder.mergeFrom(message); // no-op if message is the default message +// builder.markClean(); + } + return builder; + } + + /** + * Gets the base class interface for the field. This may either be a builder or a message. It will + * return whatever is more efficient. + * + * @return the message or builder for the field as the base class interface + */ + @SuppressWarnings("unchecked") + public IType getMessageOrBuilder() { + if (builder != null) { + return (IType) builder; + } else { + return (IType) message; + } + } + + /** + * Sets a message for the field replacing any existing value. + * + * @param message the message to set + * @return the builder + */ + // Comment out because CanIgnoreReturnValue is package private to com.google.protobuf +// @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal setMessage(MType message) { + this.message = checkNotNull(message); + if (builder != null) { +// builder.dispose(); + builder = null; + } + onChanged(); + return this; + } + + /** + * Merges the field from another field. + * + * @param value the value to merge from + * @return the builder + */ +// @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal mergeFrom(MType value) { + if (builder == null && message == message.getDefaultInstanceForType()) { + message = value; + } else { + getBuilder().mergeFrom(value); + } + onChanged(); + return this; + } + + /** + * Clears the value of the field. + * + * @return the builder + */ + @SuppressWarnings("unchecked") +// @CanIgnoreReturnValue + public SingleFieldBuilderV3Internal clear() { + message = + (MType) + (message != null + ? message.getDefaultInstanceForType() + : builder.getDefaultInstanceForType()); + if (builder != null) { +// builder.dispose(); + builder = null; + } + onChanged(); + // After clearing, parent is dirty, but this field builder is now clean and any changes should + // trickle up. + isClean = true; + return this; + } + + /** + * Called when a the builder or one of its nested children has changed and any parent should be + * notified of its invalidation. + */ + private void onChanged() { + // If builder is null, this is the case where onChanged is being called + // from setMessage or clear. + if (builder != null) { + message = null; + } + if (isClean && parent != null) { + parent.markDirty(); + + // Don't keep dispatching invalidations until build is called again. + isClean = false; + } + } + + static T checkNotNull(T obj) { + if (obj == null) { + throw new NullPointerException(); + } + return obj; + } + + @Override + public void markDirty() { + onChanged(); + } +}