Skip to content

Commit

Permalink
Merge pull request #10771 from protocolbuffers/gberg-cp-10770
Browse files Browse the repository at this point in the history
Merge pull request #10770 from protocolbuffers/googleberg-cl-480629524
  • Loading branch information
googleberg authored Oct 13, 2022
2 parents fa5a9e1 + 1594ac1 commit 4aab0bf
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,13 @@ Object buildMessageInfo() throws Exception {

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(
Expand Down

0 comments on commit 4aab0bf

Please sign in to comment.