Fix lint warnings for protobuf GeneratedMessage.java

PiperOrigin-RevId: 507937400
pull/11852/head
Protobuf Team Bot 2 years ago committed by Copybara-Service
parent c8ebeb1733
commit 1d744d40c8
  1. 12
      java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java

@ -940,7 +940,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
protected MapField internalGetMapField(int fieldNumber) { protected MapField internalGetMapField(int fieldNumber) {
// Note that we can't use descriptor names here because this method will // Note that we can't use descriptor names here because this method will
// be called when descriptor is being initialized. // be called when descriptor is being initialized.
throw new RuntimeException("No map fields found in " + getClass().getName()); throw new IllegalArgumentException("No map fields found in " + getClass().getName());
} }
/** Like {@link #internalGetMapField} but return a mutable version. */ /** Like {@link #internalGetMapField} but return a mutable version. */
@ -1988,7 +1988,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
try { try {
return clazz.getMethod(name, params); return clazz.getMethod(name, params);
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
throw new RuntimeException( throw new IllegalStateException(
"Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".", "Generated message class \"" + clazz.getName() + "\" missing method \"" + name + "\".",
e); e);
} }
@ -2001,8 +2001,8 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
try { try {
return method.invoke(object, params); return method.invoke(object, params);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
throw new RuntimeException( throw new IllegalStateException(
"Couldn't use Java reflection to implement protocol message " + "reflection.", e); "Couldn't use Java reflection to implement protocol message reflection.", e);
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
final Throwable cause = e.getCause(); final Throwable cause = e.getCause();
if (cause instanceof RuntimeException) { if (cause instanceof RuntimeException) {
@ -2010,7 +2010,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
} else if (cause instanceof Error) { } else if (cause instanceof Error) {
throw (Error) cause; throw (Error) cause;
} else { } else {
throw new RuntimeException( throw new IllegalStateException(
"Unexpected exception thrown by generated accessor method.", cause); "Unexpected exception thrown by generated accessor method.", cause);
} }
} }
@ -2029,7 +2029,7 @@ public abstract class GeneratedMessageV3 extends AbstractMessage implements Seri
protected MapField internalGetMapField(int fieldNumber) { protected MapField internalGetMapField(int fieldNumber) {
// Note that we can't use descriptor names here because this method will // Note that we can't use descriptor names here because this method will
// be called when descriptor is being initialized. // be called when descriptor is being initialized.
throw new RuntimeException("No map fields found in " + getClass().getName()); throw new IllegalArgumentException("No map fields found in " + getClass().getName());
} }
/** /**

Loading…
Cancel
Save