Migrate away from examining the syntax of a proto file via reflection.

PiperOrigin-RevId: 511806036
pull/11984/head
Sandy Zhang 2 years ago committed by Copybara-Service
parent 2a55706f9d
commit 541914157e
  1. 6
      java/util/src/main/java/com/google/protobuf/util/JsonFormat.java

@ -1925,10 +1925,10 @@ public class JsonFormat {
// Try to interpret the value as a number.
try {
int numericValue = parseInt32(json);
if (enumDescriptor.getFile().getSyntax() == FileDescriptor.Syntax.PROTO3) {
result = enumDescriptor.findValueByNumberCreatingIfUnknown(numericValue);
} else {
if (enumDescriptor.isClosed()) {
result = enumDescriptor.findValueByNumber(numericValue);
} else {
result = enumDescriptor.findValueByNumberCreatingIfUnknown(numericValue);
}
} catch (InvalidProtocolBufferException e) {
// Fall through. This exception is about invalid int32 value we get from parseInt32() but

Loading…
Cancel
Save