Update to call descriptor outer class's getDescriptor() method instead of accessing internal descriptor variable directly.

PiperOrigin-RevId: 597355223
pull/15373/head
Sandy Zhang 11 months ago committed by Copybara-Service
parent 748ab1608a
commit 592ee9b192
  1. 2
      java/core/src/main/java/com/google/protobuf/GeneratedMessage.java

@ -1613,7 +1613,7 @@ public abstract class GeneratedMessage extends AbstractMessage implements Serial
protected FieldDescriptor loadDescriptor() { protected FieldDescriptor loadDescriptor() {
try { try {
Class clazz = singularType.getClassLoader().loadClass(descriptorOuterClass); Class clazz = singularType.getClassLoader().loadClass(descriptorOuterClass);
FileDescriptor file = (FileDescriptor) clazz.getField("descriptor").get(null); FileDescriptor file = (FileDescriptor) clazz.getMethod("getDescriptor").invoke(null);
return file.findExtensionByName(extensionName); return file.findExtensionByName(extensionName);
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException( throw new RuntimeException(

Loading…
Cancel
Save