Add protobuf patch

This commit is contained in:
vshcherb 2013-11-11 01:06:14 +01:00
parent 2a736bcf07
commit 8af6fa9816
10 changed files with 184 additions and 183 deletions

View file

@ -1,6 +1,6 @@
bin bin
c-src c-src
OsmAnd-core.jar OsmAnd-core.jar
protobuf-src protobuf-src/com
OsmAnd-core-android.jar OsmAnd-core-android.jar
src/net/osmand/core/jni/* src/net/osmand/core/jni/*

View file

@ -37,6 +37,7 @@ index ad43f96..45004e2 100644
private static final int DEFAULT_SIZE_LIMIT = 64 << 20; // 64MB private static final int DEFAULT_SIZE_LIMIT = 64 << 20; // 64MB
- private static final int BUFFER_SIZE = 4096; - private static final int BUFFER_SIZE = 4096;
+ private static final int BUFFER_SIZE = 5 * 1024; + private static final int BUFFER_SIZE = 5 * 1024;
+
private CodedInputStream(final byte[] buffer, final int off, final int len) { private CodedInputStream(final byte[] buffer, final int off, final int len) {
this.buffer = buffer; this.buffer = buffer;
@ -82,8 +83,9 @@ index ad43f96..45004e2 100644
while (pos < chunk.length) { while (pos < chunk.length) {
- final int n = (input == null) ? -1 : - final int n = (input == null) ? -1 :
- input.read(chunk, pos, chunk.length - pos); - input.read(chunk, pos, chunk.length - pos);
+ // osmand change +
+ final int n; + final int n;
+ // osmand change
+ if(raf != null) { + if(raf != null) {
+ raf.readFully(chunk, pos, chunk.length - pos); + raf.readFully(chunk, pos, chunk.length - pos);
+ n = chunk.length - pos; + n = chunk.length - pos;
@ -94,6 +96,14 @@ index ad43f96..45004e2 100644
if (n == -1) { if (n == -1) {
throw InvalidProtocolBufferException.truncatedMessage(); throw InvalidProtocolBufferException.truncatedMessage();
} }
@@ -817,7 +854,6 @@ public final class CodedInputStream {
System.arraycopy(chunk, 0, bytes, pos, chunk.length);
pos += chunk.length;
}
-
// Done.
return bytes;
}
@@ -847,13 +883,19 @@ public final class CodedInputStream { @@ -847,13 +883,19 @@ public final class CodedInputStream {
} else { } else {
// Skipping more bytes than are in the buffer. First skip what we have. // Skipping more bytes than are in the buffer. First skip what we have.
@ -157,6 +167,7 @@ index ad43f96..02c1ee5 100644
* reading some other format of your own design, use the latter. * reading some other format of your own design, use the latter.
* *
* @author kenton@google.com Kenton Varda * @author kenton@google.com Kenton Varda
+ * OSMAND change
*/ */
-public final class CodedInputStream { -public final class CodedInputStream {
+public final class CodedInputStreamRAF { +public final class CodedInputStreamRAF {
@ -189,6 +200,63 @@ index ad43f96..02c1ee5 100644
// ----------------------------------------------------------------- // -----------------------------------------------------------------
@@ -210,55 +203,8 @@ public final class CodedInputStream {
}
}
- /** Read a {@code group} field value from the stream. */
- public void readGroup(final int fieldNumber,
- final MessageLite.Builder builder,
- final ExtensionRegistryLite extensionRegistry)
- throws IOException {
- if (recursionDepth >= recursionLimit) {
- throw InvalidProtocolBufferException.recursionLimitExceeded();
- }
- ++recursionDepth;
- builder.mergeFrom(this, extensionRegistry);
- checkLastTagWas(
- WireFormat.makeTag(fieldNumber, WireFormat.WIRETYPE_END_GROUP));
- --recursionDepth;
- }
- /**
- * Reads a {@code group} field value from the stream and merges it into the
- * given {@link UnknownFieldSet}.
- *
- * @deprecated UnknownFieldSet.Builder now implements MessageLite.Builder, so
- * you can just call {@link #readGroup}.
- */
- @Deprecated
- public void readUnknownGroup(final int fieldNumber,
- final MessageLite.Builder builder)
- throws IOException {
- // We know that UnknownFieldSet will ignore any ExtensionRegistry so it
- // is safe to pass null here. (We can't call
- // ExtensionRegistry.getEmptyRegistry() because that would make this
- // class depend on ExtensionRegistry, which is not part of the lite
- // library.)
- readGroup(fieldNumber, builder, null);
- }
-
- /** Read an embedded message field value from the stream. */
- public void readMessage(final MessageLite.Builder builder,
- final ExtensionRegistryLite extensionRegistry)
- throws IOException {
- final int length = readRawVarint32();
- if (recursionDepth >= recursionLimit) {
- throw InvalidProtocolBufferException.recursionLimitExceeded();
- }
- final int oldLimit = pushLimit(length);
- ++recursionDepth;
- builder.mergeFrom(this, extensionRegistry);
- checkLastTagWas(0);
- --recursionDepth;
- popLimit(oldLimit);
- }
+
/** Read a {@code bytes} field value from the stream. */
public ByteString readBytes() throws IOException {
@@ -480,7 +426,7 @@ public final class CodedInputStream { @@ -480,7 +426,7 @@ public final class CodedInputStream {
private int bufferSize; private int bufferSize;
private int bufferSizeAfterLimit; private int bufferSizeAfterLimit;
@ -291,6 +359,16 @@ diff --git b/OsmAnd-java/src/com/google/protobuf/CodedOutputStream.java a/OsmAnd
index 58dd150..6e81b98 100644 index 58dd150..6e81b98 100644
--- b/OsmAnd-java/src/com/google/protobuf/CodedOutputStream.java --- b/OsmAnd-java/src/com/google/protobuf/CodedOutputStream.java
+++ a/OsmAnd-java/src/com/google/protobuf/CodedOutputStream.java +++ a/OsmAnd-java/src/com/google/protobuf/CodedOutputStream.java
@@ -30,8 +30,8 @@
package com.google.protobuf;
-import java.io.OutputStream;
import java.io.IOException;
+import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
/**
@@ -52,6 +52,8 @@ public final class CodedOutputStream { @@ -52,6 +52,8 @@ public final class CodedOutputStream {
private final byte[] buffer; private final byte[] buffer;
private final int limit; private final int limit;
@ -334,7 +412,7 @@ diff --git b/OsmAnd-java/src/com/google/protobuf/WireFormat.java a/OsmAnd-java/s
index c46f7b0..cca0b8e 100644 index c46f7b0..cca0b8e 100644
--- b/OsmAnd-java/src/com/google/protobuf/WireFormat.java --- b/OsmAnd-java/src/com/google/protobuf/WireFormat.java
+++ a/OsmAnd-java/src/com/google/protobuf/WireFormat.java +++ a/OsmAnd-java/src/com/google/protobuf/WireFormat.java
@@ -51,12 +51,14 @@ public final class WireFormat { @@ -51,11 +51,13 @@ public final class WireFormat {
static final int WIRETYPE_START_GROUP = 3; static final int WIRETYPE_START_GROUP = 3;
static final int WIRETYPE_END_GROUP = 4; static final int WIRETYPE_END_GROUP = 4;
static final int WIRETYPE_FIXED32 = 5; static final int WIRETYPE_FIXED32 = 5;
@ -349,3 +427,4 @@ index c46f7b0..cca0b8e 100644
+ public static int getTagWireType(final int tag) { + public static int getTagWireType(final int tag) {
return tag & TAG_TYPE_MASK; return tag & TAG_TYPE_MASK;
} }

View file

@ -0,0 +1,5 @@
#!/bin/bash
mkdir -p ../src/com
cp com/google/protobuf/CodedInputStream.java com/google/protobuf/CodedInputStreamRAF.java
cp -Rf com/* ../src/com/
git apply -v protobuf-2.3.patch

View file

@ -30,13 +30,13 @@
package com.google.protobuf; package com.google.protobuf;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
/** /**
* A table of known extensions, searchable by name or field number. When * A table of known extensions, searchable by name or field number. When
* parsing a protocol message that might have extensions, you must provide * parsing a protocol message that might have extensions, you must provide

View file

@ -30,13 +30,13 @@
package com.google.protobuf; package com.google.protobuf;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
import java.util.TreeMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.io.IOException;
/** /**
* A class which represents an arbitrary set of fields of some message type. * A class which represents an arbitrary set of fields of some message type.
@ -210,7 +210,7 @@ final class FieldSet<FieldDescriptorType extends
if (value == null) { if (value == null) {
return 0; return 0;
} else { } else {
return ((List<?>) value).size(); return ((List) value).size();
} }
} }
@ -218,8 +218,7 @@ final class FieldSet<FieldDescriptorType extends
* Useful for implementing * Useful for implementing
* {@link Message#getRepeatedField(Descriptors.FieldDescriptor,int)}. * {@link Message#getRepeatedField(Descriptors.FieldDescriptor,int)}.
*/ */
@SuppressWarnings("unchecked") public Object getRepeatedField(final FieldDescriptorType descriptor,
public Object getRepeatedField(final FieldDescriptorType descriptor,
final int index) { final int index) {
if (!descriptor.isRepeated()) { if (!descriptor.isRepeated()) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -558,8 +557,7 @@ public Object getRepeatedField(final FieldDescriptorType descriptor,
} }
/** Write a single field. */ /** Write a single field. */
@SuppressWarnings("unchecked") public static void writeField(final FieldDescriptorLite<?> descriptor,
public static void writeField(final FieldDescriptorLite<?> descriptor,
final Object value, final Object value,
final CodedOutputStream output) final CodedOutputStream output)
throws IOException { throws IOException {
@ -687,8 +685,7 @@ public static void writeField(final FieldDescriptorLite<?> descriptor,
/** /**
* Compute the number of bytes needed to encode a particular field. * Compute the number of bytes needed to encode a particular field.
*/ */
@SuppressWarnings("unchecked") public static int computeFieldSize(final FieldDescriptorLite<?> descriptor,
public static int computeFieldSize(final FieldDescriptorLite<?> descriptor,
final Object value) { final Object value) {
WireFormat.FieldType type = descriptor.getLiteType(); WireFormat.FieldType type = descriptor.getLiteType();
int number = descriptor.getNumber(); int number = descriptor.getNumber();

View file

@ -30,9 +30,13 @@
package com.google.protobuf; package com.google.protobuf;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@ -40,10 +44,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
import com.google.protobuf.Descriptors.Descriptor;
import com.google.protobuf.Descriptors.EnumValueDescriptor;
import com.google.protobuf.Descriptors.FieldDescriptor;
/** /**
* All generated protocol message classes extend this class. This class * All generated protocol message classes extend this class. This class
* implements most of the Message and Builder interfaces using Java reflection. * implements most of the Message and Builder interfaces using Java reflection.
@ -64,14 +64,12 @@ public abstract class GeneratedMessage extends AbstractMessage {
*/ */
protected abstract FieldAccessorTable internalGetFieldAccessorTable(); protected abstract FieldAccessorTable internalGetFieldAccessorTable();
@Override public Descriptor getDescriptorForType() {
public Descriptor getDescriptorForType() {
return internalGetFieldAccessorTable().descriptor; return internalGetFieldAccessorTable().descriptor;
} }
/** Internal helper which returns a mutable map. */ /** Internal helper which returns a mutable map. */
@SuppressWarnings("unchecked") private Map<FieldDescriptor, Object> getAllFieldsMutable() {
private Map<FieldDescriptor, Object> getAllFieldsMutable() {
final TreeMap<FieldDescriptor, Object> result = final TreeMap<FieldDescriptor, Object> result =
new TreeMap<FieldDescriptor, Object>(); new TreeMap<FieldDescriptor, Object>();
final Descriptor descriptor = internalGetFieldAccessorTable().descriptor; final Descriptor descriptor = internalGetFieldAccessorTable().descriptor;
@ -102,8 +100,7 @@ private Map<FieldDescriptor, Object> getAllFieldsMutable() {
// Check that embedded messages are initialized. // Check that embedded messages are initialized.
if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) { if (field.getJavaType() == FieldDescriptor.JavaType.MESSAGE) {
if (field.isRepeated()) { if (field.isRepeated()) {
// Osmand fix (remove annotation) @SuppressWarnings("unchecked") final
final
List<Message> messageList = (List<Message>) getField(field); List<Message> messageList = (List<Message>) getField(field);
for (final Message element : messageList) { for (final Message element : messageList) {
if (!element.isInitialized()) { if (!element.isInitialized()) {
@ -121,35 +118,29 @@ private Map<FieldDescriptor, Object> getAllFieldsMutable() {
return true; return true;
} }
@Override public Map<FieldDescriptor, Object> getAllFields() {
public Map<FieldDescriptor, Object> getAllFields() {
return Collections.unmodifiableMap(getAllFieldsMutable()); return Collections.unmodifiableMap(getAllFieldsMutable());
} }
@Override public boolean hasField(final FieldDescriptor field) {
public boolean hasField(final FieldDescriptor field) {
return internalGetFieldAccessorTable().getField(field).has(this); return internalGetFieldAccessorTable().getField(field).has(this);
} }
@Override public Object getField(final FieldDescriptor field) {
public Object getField(final FieldDescriptor field) {
return internalGetFieldAccessorTable().getField(field).get(this); return internalGetFieldAccessorTable().getField(field).get(this);
} }
@Override public int getRepeatedFieldCount(final FieldDescriptor field) {
public int getRepeatedFieldCount(final FieldDescriptor field) {
return internalGetFieldAccessorTable().getField(field) return internalGetFieldAccessorTable().getField(field)
.getRepeatedCount(this); .getRepeatedCount(this);
} }
@Override public Object getRepeatedField(final FieldDescriptor field, final int index) {
public Object getRepeatedField(final FieldDescriptor field, final int index) {
return internalGetFieldAccessorTable().getField(field) return internalGetFieldAccessorTable().getField(field)
.getRepeated(this, index); .getRepeated(this, index);
} }
@Override public final UnknownFieldSet getUnknownFields() {
public final UnknownFieldSet getUnknownFields() {
return unknownFields; return unknownFields;
} }
@ -182,28 +173,23 @@ public final UnknownFieldSet getUnknownFields() {
return internalGetResult().internalGetFieldAccessorTable(); return internalGetResult().internalGetFieldAccessorTable();
} }
@Override
public Descriptor getDescriptorForType() { public Descriptor getDescriptorForType() {
return internalGetFieldAccessorTable().descriptor; return internalGetFieldAccessorTable().descriptor;
} }
@Override
public Map<FieldDescriptor, Object> getAllFields() { public Map<FieldDescriptor, Object> getAllFields() {
return internalGetResult().getAllFields(); return internalGetResult().getAllFields();
} }
@Override
public Message.Builder newBuilderForField( public Message.Builder newBuilderForField(
final FieldDescriptor field) { final FieldDescriptor field) {
return internalGetFieldAccessorTable().getField(field).newBuilder(); return internalGetFieldAccessorTable().getField(field).newBuilder();
} }
@Override
public boolean hasField(final FieldDescriptor field) { public boolean hasField(final FieldDescriptor field) {
return internalGetResult().hasField(field); return internalGetResult().hasField(field);
} }
@Override
public Object getField(final FieldDescriptor field) { public Object getField(final FieldDescriptor field) {
if (field.isRepeated()) { if (field.isRepeated()) {
// The underlying list object is still modifiable at this point. // The underlying list object is still modifiable at this point.
@ -215,31 +201,26 @@ public final UnknownFieldSet getUnknownFields() {
} }
} }
@Override
public BuilderType setField(final FieldDescriptor field, public BuilderType setField(final FieldDescriptor field,
final Object value) { final Object value) {
internalGetFieldAccessorTable().getField(field).set(this, value); internalGetFieldAccessorTable().getField(field).set(this, value);
return (BuilderType) this; return (BuilderType) this;
} }
@Override
public BuilderType clearField(final FieldDescriptor field) { public BuilderType clearField(final FieldDescriptor field) {
internalGetFieldAccessorTable().getField(field).clear(this); internalGetFieldAccessorTable().getField(field).clear(this);
return (BuilderType) this; return (BuilderType) this;
} }
@Override
public int getRepeatedFieldCount(final FieldDescriptor field) { public int getRepeatedFieldCount(final FieldDescriptor field) {
return internalGetResult().getRepeatedFieldCount(field); return internalGetResult().getRepeatedFieldCount(field);
} }
@Override
public Object getRepeatedField(final FieldDescriptor field, public Object getRepeatedField(final FieldDescriptor field,
final int index) { final int index) {
return internalGetResult().getRepeatedField(field, index); return internalGetResult().getRepeatedField(field, index);
} }
@Override
public BuilderType setRepeatedField(final FieldDescriptor field, public BuilderType setRepeatedField(final FieldDescriptor field,
final int index, final Object value) { final int index, final Object value) {
internalGetFieldAccessorTable().getField(field) internalGetFieldAccessorTable().getField(field)
@ -247,19 +228,16 @@ public final UnknownFieldSet getUnknownFields() {
return (BuilderType) this; return (BuilderType) this;
} }
@Override
public BuilderType addRepeatedField(final FieldDescriptor field, public BuilderType addRepeatedField(final FieldDescriptor field,
final Object value) { final Object value) {
internalGetFieldAccessorTable().getField(field).addRepeated(this, value); internalGetFieldAccessorTable().getField(field).addRepeated(this, value);
return (BuilderType) this; return (BuilderType) this;
} }
@Override
public final UnknownFieldSet getUnknownFields() { public final UnknownFieldSet getUnknownFields() {
return internalGetResult().unknownFields; return internalGetResult().unknownFields;
} }
@Override
public final BuilderType setUnknownFields( public final BuilderType setUnknownFields(
final UnknownFieldSet unknownFields) { final UnknownFieldSet unknownFields) {
internalGetResult().unknownFields = unknownFields; internalGetResult().unknownFields = unknownFields;
@ -277,7 +255,6 @@ public final UnknownFieldSet getUnknownFields() {
return (BuilderType) this; return (BuilderType) this;
} }
@Override
public boolean isInitialized() { public boolean isInitialized() {
return internalGetResult().isInitialized(); return internalGetResult().isInitialized();
} }
@ -361,8 +338,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Get the number of elements in a repeated extension. */ /** Get the number of elements in a repeated extension. */
public final <Type> int getExtensionCount( public final <Type> int getExtensionCount(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension) {
final GeneratedExtension<MessageType, List<Type> > extension) {
verifyExtensionContainingType(extension); verifyExtensionContainingType(extension);
final FieldDescriptor descriptor = extension.getDescriptor(); final FieldDescriptor descriptor = extension.getDescriptor();
return extensions.getRepeatedFieldCount(descriptor); return extensions.getRepeatedFieldCount(descriptor);
@ -393,8 +369,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Get one element of a repeated extension. */ /** Get one element of a repeated extension. */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public final <Type> Type getExtension( public final <Type> Type getExtension(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension,
final GeneratedExtension<MessageType, List<Type> > extension,
final int index) { final int index) {
verifyExtensionContainingType(extension); verifyExtensionContainingType(extension);
FieldDescriptor descriptor = extension.getDescriptor(); FieldDescriptor descriptor = extension.getDescriptor();
@ -421,8 +396,8 @@ public final UnknownFieldSet getUnknownFields() {
protected class ExtensionWriter { protected class ExtensionWriter {
// Imagine how much simpler this code would be if Java iterators had // Imagine how much simpler this code would be if Java iterators had
// a way to get the next element without advancing the iterator. // a way to get the next element without advancing the iterator.
// osmand fix >> -> > >
private final Iterator<Map.Entry<FieldDescriptor, Object> > iter = private final Iterator<Map.Entry<FieldDescriptor, Object>> iter =
extensions.iterator(); extensions.iterator();
private Map.Entry<FieldDescriptor, Object> next; private Map.Entry<FieldDescriptor, Object> next;
private final boolean messageSetWireFormat; private final boolean messageSetWireFormat;
@ -604,8 +579,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Get the number of elements in a repeated extension. */ /** Get the number of elements in a repeated extension. */
public final <Type> int getExtensionCount( public final <Type> int getExtensionCount(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension) {
final GeneratedExtension<MessageType, List<Type> > extension) {
return internalGetResult().getExtensionCount(extension); return internalGetResult().getExtensionCount(extension);
} }
@ -617,8 +591,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Get one element of a repeated extension. */ /** Get one element of a repeated extension. */
public final <Type> Type getExtension( public final <Type> Type getExtension(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension,
final GeneratedExtension<MessageType, List<Type> > extension,
final int index) { final int index) {
return internalGetResult().getExtension(extension, index); return internalGetResult().getExtension(extension, index);
} }
@ -637,8 +610,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Set the value of one element of a repeated extension. */ /** Set the value of one element of a repeated extension. */
public final <Type> BuilderType setExtension( public final <Type> BuilderType setExtension(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension,
final GeneratedExtension<MessageType, List<Type> > extension,
final int index, final Type value) { final int index, final Type value) {
final ExtendableMessage<MessageType> message = internalGetResult(); final ExtendableMessage<MessageType> message = internalGetResult();
message.verifyExtensionContainingType(extension); message.verifyExtensionContainingType(extension);
@ -651,8 +623,7 @@ public final UnknownFieldSet getUnknownFields() {
/** Append a value to a repeated extension. */ /** Append a value to a repeated extension. */
public final <Type> BuilderType addExtension( public final <Type> BuilderType addExtension(
// osmand fix >> -> > > final GeneratedExtension<MessageType, List<Type>> extension,
final GeneratedExtension<MessageType, List<Type> > extension,
final Type value) { final Type value) {
final ExtendableMessage<MessageType> message = internalGetResult(); final ExtendableMessage<MessageType> message = internalGetResult();
message.verifyExtensionContainingType(extension); message.verifyExtensionContainingType(extension);
@ -1091,45 +1062,36 @@ public final UnknownFieldSet getUnknownFields() {
protected final Method hasMethod; protected final Method hasMethod;
protected final Method clearMethod; protected final Method clearMethod;
@Override
public Object get(final GeneratedMessage message) { public Object get(final GeneratedMessage message) {
return invokeOrDie(getMethod, message); return invokeOrDie(getMethod, message);
} }
@Override
public void set(final Builder builder, final Object value) { public void set(final Builder builder, final Object value) {
invokeOrDie(setMethod, builder, value); invokeOrDie(setMethod, builder, value);
} }
@Override
public Object getRepeated(final GeneratedMessage message, public Object getRepeated(final GeneratedMessage message,
final int index) { final int index) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"getRepeatedField() called on a singular field."); "getRepeatedField() called on a singular field.");
} }
@Override
public void setRepeated(final Builder builder, public void setRepeated(final Builder builder,
final int index, final Object value) { final int index, final Object value) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"setRepeatedField() called on a singular field."); "setRepeatedField() called on a singular field.");
} }
@Override
public void addRepeated(final Builder builder, final Object value) { public void addRepeated(final Builder builder, final Object value) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"addRepeatedField() called on a singular field."); "addRepeatedField() called on a singular field.");
} }
@Override
public boolean has(final GeneratedMessage message) { public boolean has(final GeneratedMessage message) {
return (Boolean) invokeOrDie(hasMethod, message); return (Boolean) invokeOrDie(hasMethod, message);
} }
@Override
public int getRepeatedCount(final GeneratedMessage message) { public int getRepeatedCount(final GeneratedMessage message) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"getRepeatedFieldSize() called on a singular field."); "getRepeatedFieldSize() called on a singular field.");
} }
@Override
public void clear(final Builder builder) { public void clear(final Builder builder) {
invokeOrDie(clearMethod, builder); invokeOrDie(clearMethod, builder);
} }
@Override
public Message.Builder newBuilder() { public Message.Builder newBuilder() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"newBuilderForField() called on a non-Message type."); "newBuilderForField() called on a non-Message type.");
@ -1166,11 +1128,9 @@ public final UnknownFieldSet getUnknownFields() {
protected final Method getCountMethod; protected final Method getCountMethod;
protected final Method clearMethod; protected final Method clearMethod;
@Override
public Object get(final GeneratedMessage message) { public Object get(final GeneratedMessage message) {
return invokeOrDie(getMethod, message); return invokeOrDie(getMethod, message);
} }
@Override
public void set(final Builder builder, final Object value) { public void set(final Builder builder, final Object value) {
// Add all the elements individually. This serves two purposes: // Add all the elements individually. This serves two purposes:
// 1) Verifies that each element has the correct type. // 1) Verifies that each element has the correct type.
@ -1181,34 +1141,27 @@ public final UnknownFieldSet getUnknownFields() {
addRepeated(builder, element); addRepeated(builder, element);
} }
} }
@Override
public Object getRepeated(final GeneratedMessage message, public Object getRepeated(final GeneratedMessage message,
final int index) { final int index) {
return invokeOrDie(getRepeatedMethod, message, index); return invokeOrDie(getRepeatedMethod, message, index);
} }
@Override
public void setRepeated(final Builder builder, public void setRepeated(final Builder builder,
final int index, final Object value) { final int index, final Object value) {
invokeOrDie(setRepeatedMethod, builder, index, value); invokeOrDie(setRepeatedMethod, builder, index, value);
} }
@Override
public void addRepeated(final Builder builder, final Object value) { public void addRepeated(final Builder builder, final Object value) {
invokeOrDie(addRepeatedMethod, builder, value); invokeOrDie(addRepeatedMethod, builder, value);
} }
@Override
public boolean has(final GeneratedMessage message) { public boolean has(final GeneratedMessage message) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"hasField() called on a singular field."); "hasField() called on a singular field.");
} }
@Override
public int getRepeatedCount(final GeneratedMessage message) { public int getRepeatedCount(final GeneratedMessage message) {
return (Integer) invokeOrDie(getCountMethod, message); return (Integer) invokeOrDie(getCountMethod, message);
} }
@Override
public void clear(final Builder builder) { public void clear(final Builder builder) {
invokeOrDie(clearMethod, builder); invokeOrDie(clearMethod, builder);
} }
@Override
public Message.Builder newBuilder() { public Message.Builder newBuilder() {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"newBuilderForField() called on a non-Message type."); "newBuilderForField() called on a non-Message type.");

View file

@ -63,7 +63,6 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite {
public abstract BuilderType mergeFrom(MessageType message); public abstract BuilderType mergeFrom(MessageType message);
// Defined here for return type covariance. // Defined here for return type covariance.
@Override
public abstract MessageType getDefaultInstanceForType(); public abstract MessageType getDefaultInstanceForType();
/** /**
@ -447,44 +446,36 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite {
private final boolean isRepeated; private final boolean isRepeated;
private final boolean isPacked; private final boolean isPacked;
@Override
public int getNumber() { public int getNumber() {
return number; return number;
} }
@Override
public WireFormat.FieldType getLiteType() { public WireFormat.FieldType getLiteType() {
return type; return type;
} }
@Override
public WireFormat.JavaType getLiteJavaType() { public WireFormat.JavaType getLiteJavaType() {
return type.getJavaType(); return type.getJavaType();
} }
@Override
public boolean isRepeated() { public boolean isRepeated() {
return isRepeated; return isRepeated;
} }
@Override
public boolean isPacked() { public boolean isPacked() {
return isPacked; return isPacked;
} }
@Override
public Internal.EnumLiteMap<?> getEnumType() { public Internal.EnumLiteMap<?> getEnumType() {
return enumTypeMap; return enumTypeMap;
} }
@Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public MessageLite.Builder internalMergeFrom( public MessageLite.Builder internalMergeFrom(
MessageLite.Builder to, MessageLite from) { MessageLite.Builder to, MessageLite from) {
return ((Builder) to).mergeFrom((GeneratedMessageLite) from); return ((Builder) to).mergeFrom((GeneratedMessageLite) from);
} }
@Override
public int compareTo(ExtensionDescriptor other) { public int compareTo(ExtensionDescriptor other) {
return number - other.number; return number - other.number;
} }
@ -533,7 +524,6 @@ public abstract class GeneratedMessageLite extends AbstractMessageLite {
} }
/** For use by generated code only. */ /** For use by generated code only. */
@SuppressWarnings("unchecked")
public void internalInitRepeated( public void internalInitRepeated(
final ContainingType containingTypeDefaultInstance, final ContainingType containingTypeDefaultInstance,
final MessageLite messageDefaultInstance, final MessageLite messageDefaultInstance,

View file

@ -59,8 +59,7 @@ public interface Message extends MessageLite {
Descriptors.Descriptor getDescriptorForType(); Descriptors.Descriptor getDescriptorForType();
// (From MessageLite, re-declared here only for return type covariance.) // (From MessageLite, re-declared here only for return type covariance.)
@Override Message getDefaultInstanceForType();
Message getDefaultInstanceForType();
/** /**
* Returns a collection of all the fields in this message which are set * Returns a collection of all the fields in this message which are set
@ -153,10 +152,8 @@ Message getDefaultInstanceForType();
// Builders // Builders
// (From MessageLite, re-declared here only for return type covariance.) // (From MessageLite, re-declared here only for return type covariance.)
@Override Builder newBuilderForType();
Builder newBuilderForType(); Builder toBuilder();
@Override
Builder toBuilder();
/** /**
* Abstract interface implemented by Protocol Message builders. * Abstract interface implemented by Protocol Message builders.
@ -164,7 +161,6 @@ Builder toBuilder();
interface Builder extends MessageLite.Builder { interface Builder extends MessageLite.Builder {
// (From MessageLite.Builder, re-declared here only for return type // (From MessageLite.Builder, re-declared here only for return type
// covariance.) // covariance.)
@Override
Builder clear(); Builder clear();
/** /**
@ -187,15 +183,10 @@ Builder toBuilder();
// (From MessageLite.Builder, re-declared here only for return type // (From MessageLite.Builder, re-declared here only for return type
// covariance.) // covariance.)
@Override
Message build(); Message build();
@Override
Message buildPartial(); Message buildPartial();
@Override
Builder clone(); Builder clone();
@Override
Builder mergeFrom(CodedInputStream input) throws IOException; Builder mergeFrom(CodedInputStream input) throws IOException;
@Override
Builder mergeFrom(CodedInputStream input, Builder mergeFrom(CodedInputStream input,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws IOException; throws IOException;
@ -208,7 +199,6 @@ Builder toBuilder();
// (From MessageLite.Builder, re-declared here only for return type // (From MessageLite.Builder, re-declared here only for return type
// covariance.) // covariance.)
@Override
Message getDefaultInstanceForType(); Message getDefaultInstanceForType();
/** /**
@ -289,35 +279,25 @@ Builder toBuilder();
// (From MessageLite.Builder, re-declared here only for return type // (From MessageLite.Builder, re-declared here only for return type
// covariance.) // covariance.)
@Override
Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException; Builder mergeFrom(ByteString data) throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(ByteString data, Builder mergeFrom(ByteString data,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException; throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException; Builder mergeFrom(byte[] data) throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(byte[] data, int off, int len) Builder mergeFrom(byte[] data, int off, int len)
throws InvalidProtocolBufferException; throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(byte[] data, Builder mergeFrom(byte[] data,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException; throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(byte[] data, int off, int len, Builder mergeFrom(byte[] data, int off, int len,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws InvalidProtocolBufferException; throws InvalidProtocolBufferException;
@Override
Builder mergeFrom(InputStream input) throws IOException; Builder mergeFrom(InputStream input) throws IOException;
@Override
Builder mergeFrom(InputStream input, Builder mergeFrom(InputStream input,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws IOException; throws IOException;
@Override
boolean mergeDelimitedFrom(InputStream input) boolean mergeDelimitedFrom(InputStream input)
throws IOException; throws IOException;
@Override
boolean mergeDelimitedFrom(InputStream input, boolean mergeDelimitedFrom(InputStream input,
ExtensionRegistryLite extensionRegistry) ExtensionRegistryLite extensionRegistry)
throws IOException; throws IOException;

View file

@ -42,8 +42,7 @@ public interface ProtocolMessageEnum extends Internal.EnumLite {
/** /**
* Return the value's numeric value as defined in the .proto file. * Return the value's numeric value as defined in the .proto file.
*/ */
@Override int getNumber();
int getNumber();
/** /**
* Return the value's descriptor, which contains information such as * Return the value's descriptor, which contains information such as

View file

@ -71,7 +71,6 @@ public final class RpcUtil {
final Class<Type> originalClass, final Class<Type> originalClass,
final Type defaultInstance) { final Type defaultInstance) {
return new RpcCallback<Message>() { return new RpcCallback<Message>() {
@Override
public void run(final Message parameter) { public void run(final Message parameter) {
Type typedParameter; Type typedParameter;
try { try {
@ -109,7 +108,6 @@ public final class RpcUtil {
return new RpcCallback<ParameterType>() { return new RpcCallback<ParameterType>() {
private boolean alreadyCalled = false; private boolean alreadyCalled = false;
@Override
public void run(final ParameterType parameter) { public void run(final ParameterType parameter) {
synchronized(this) { synchronized(this) {
if (alreadyCalled) { if (alreadyCalled) {