Merge pull request #10771 from protocolbuffers/gberg-cp-10770

Merge pull request #10770 from protocolbuffers/googleberg-cl-480629524
pull/10772/head
Jerry Berg 2 years ago committed by GitHub
commit 4aab0bf621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java

@ -407,8 +407,13 @@ public abstract class GeneratedMessageLite<
protected static <T extends GeneratedMessageLite<?, ?>> void registerDefaultInstance(
Class<T> clazz, T defaultInstance) {
// Default instances must be immutable.
// Marking immutable here to avoid extra bytecode in every generated message class.
// Only calling "markImmutable" rather than "makeImmutable" because for Default Instances:
// 1. All sub-messages are initialized to null / default instances and thus immutable
// 2. All lists are initialized to default instance empty lists which are also immutable.
defaultInstance.markImmutable();
defaultInstanceMap.put(clazz, defaultInstance);
defaultInstance.makeImmutable();
}
protected static Object newMessageInfo(

Loading…
Cancel
Save