Merge pull request #2825 from pherl/javawarning
Cherry-pick changes from javalite branch to also fix Java warnings in the master branch
This commit is contained in:
commit
a1bb147e96
@ -854,6 +854,7 @@ public abstract class GeneratedMessage extends AbstractMessage
|
||||
|
||||
/** Check if a singular extension is present. */
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
|
||||
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
|
||||
|
||||
@ -863,6 +864,7 @@ public abstract class GeneratedMessage extends AbstractMessage
|
||||
|
||||
/** Get the number of elements in a repeated extension. */
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <Type> int getExtensionCount(
|
||||
final ExtensionLite<MessageType, List<Type>> extensionLite) {
|
||||
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
|
||||
@ -2555,6 +2557,7 @@ public abstract class GeneratedMessage extends AbstractMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object get(GeneratedMessage message) {
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < getRepeatedCount(message); i++) {
|
||||
@ -2564,6 +2567,7 @@ public abstract class GeneratedMessage extends AbstractMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object get(Builder builder) {
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < getRepeatedCount(builder); i++) {
|
||||
|
@ -220,6 +220,7 @@ public abstract class GeneratedMessageLite<
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final BuilderType toBuilder() {
|
||||
BuilderType builder = (BuilderType) dynamicMethod(MethodToInvoke.NEW_BUILDER);
|
||||
builder.mergeFrom((MessageType) this);
|
||||
@ -453,6 +454,7 @@ public abstract class GeneratedMessageLite<
|
||||
*/
|
||||
protected FieldSet<ExtensionDescriptor> extensions = FieldSet.newFieldSet();
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected final void mergeExtensionFields(final MessageType other) {
|
||||
if (extensions.isImmutable()) {
|
||||
extensions = extensions.clone();
|
||||
|
@ -866,6 +866,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
|
||||
|
||||
/** Check if a singular extension is present. */
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <Type> boolean hasExtension(final ExtensionLite<MessageType, Type> extensionLite) {
|
||||
Extension<MessageType, Type> extension = checkNotLite(extensionLite);
|
||||
|
||||
@ -875,6 +876,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
|
||||
|
||||
/** Get the number of elements in a repeated extension. */
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public final <Type> int getExtensionCount(
|
||||
final ExtensionLite<MessageType, List<Type>> extensionLite) {
|
||||
Extension<MessageType, List<Type>> extension = checkNotLite(extensionLite);
|
||||
@ -2219,6 +2221,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object get(GeneratedMessageV3 message) {
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < getRepeatedCount(message); i++) {
|
||||
@ -2228,6 +2231,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Object get(Builder builder) {
|
||||
List result = new ArrayList();
|
||||
for (int i = 0; i < getRepeatedCount(builder); i++) {
|
||||
|
@ -89,6 +89,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
|
||||
}
|
||||
|
||||
/** Create a MapEntry with the provided key and value. */
|
||||
@SuppressWarnings("unchecked")
|
||||
private MapEntry(Metadata metadata, K key, V value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
@ -435,6 +436,7 @@ public final class MapEntry<K, V> extends AbstractMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public Builder<K, V> clone() {
|
||||
return new Builder(metadata, key, value);
|
||||
}
|
||||
|
@ -100,6 +100,7 @@ public class MapField<K, V> implements MutabilityOracle {
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public void convertMessageToKeyAndValue(Message message, Map<K, V> map) {
|
||||
MapEntry<K, V> entry = (MapEntry<K, V>) message;
|
||||
map.put(entry.getKey(), entry.getValue());
|
||||
|
@ -1453,6 +1453,7 @@ void ImmutableMessageGenerator::GenerateAnyMethods(io::Printer* printer) {
|
||||
"\n"
|
||||
"private volatile com.google.protobuf.Message cachedUnpackValue;\n"
|
||||
"\n"
|
||||
"@java.lang.SuppressWarnings(\"unchecked\")\n"
|
||||
"public <T extends com.google.protobuf.Message> T unpack(\n"
|
||||
" java.lang.Class<T> clazz)\n"
|
||||
" throws com.google.protobuf.InvalidProtocolBufferException {\n"
|
||||
|
@ -345,6 +345,7 @@ void ImmutableMessageLiteGenerator::Generate(io::Printer* printer) {
|
||||
}
|
||||
|
||||
printer->Print(
|
||||
"@java.lang.SuppressWarnings(\"unchecked\")\n"
|
||||
"protected final Object dynamicMethod(\n"
|
||||
" com.google.protobuf.GeneratedMessageLite.MethodToInvoke method,\n"
|
||||
" Object arg0, Object arg1) {\n"
|
||||
|
Loading…
Reference in New Issue
Block a user