If all of your types are lite types, then you only need to use ExtensionRegistryLite.
Similarly, if all your types are regular types, then you only need ExtensionRegistry.
Typically it does not make sense to mix the two, since if you have any regular types in your
program, you then require the full runtime and lose all the benefits of the lite runtime, so you
might as well make all your types be regular types. However, in some cases (e.g. when depending
on multiple third-party libraries where one uses lite types and one uses regular), you may find
yourself wanting to mix the two. In this case things get more complicated.
There are three factors to consider: Whether the type being extended is lite, whether the
embedded type (in the case of a message-typed extension) is lite, and whether the extension
itself is lite. Since all three are declared in different files, they could all be different.
Here are all the combinations and which type of registry to use:
Extended type Inner type Extension Use registry
lite lite lite ExtensionRegistryLite
lite regular lite ExtensionRegistry
regular regular regular ExtensionRegistry
all other combinations not supported
Note that just as regular types are not allowed to contain lite-type fields, they are also not
allowed to contain lite-type extensions. This is because regular types must be fully accessible
via reflection, which in turn means that all the inner messages must also support reflection. On
the other hand, since regular types implement the entire lite interface, there is no problem with
embedding regular types inside lite types.
Get the unmodifiable singleton empty instance of either ExtensionRegistryLite or
ExtensionRegistry (if the full (non-Lite) proto libraries are available).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-07 UTC."],[],[],null,["# Class ExtensionRegistryLite (3.19.4)\n\n public class ExtensionRegistryLite\n\nEquivalent to [ExtensionRegistry](/java/docs/reference/protobuf/latest/com.google.protobuf.ExtensionRegistry) but supports only \"lite\" types.\n\nIf all of your types are lite types, then you only need to use `ExtensionRegistryLite`.\nSimilarly, if all your types are regular types, then you only need [ExtensionRegistry](/java/docs/reference/protobuf/latest/com.google.protobuf.ExtensionRegistry).\nTypically it does not make sense to mix the two, since if you have any regular types in your\nprogram, you then require the full runtime and lose all the benefits of the lite runtime, so you\nmight as well make all your types be regular types. However, in some cases (e.g. when depending\non multiple third-party libraries where one uses lite types and one uses regular), you may find\nyourself wanting to mix the two. In this case things get more complicated.\n\nThere are three factors to consider: Whether the type being extended is lite, whether the\nembedded type (in the case of a message-typed extension) is lite, and whether the extension\nitself is lite. Since all three are declared in different files, they could all be different.\nHere are all the combinations and which type of registry to use:\n\nExtended type Inner type Extension Use registry\n===============================================\n\nlite lite lite ExtensionRegistryLite\nlite regular lite ExtensionRegistry\nregular regular regular ExtensionRegistry\nall other combinations not supported\n\nNote that just as regular types are not allowed to contain lite-type fields, they are also not\nallowed to contain lite-type extensions. This is because regular types must be fully accessible\nvia reflection, which in turn means that all the inner messages must also support reflection. On\nthe other hand, since regular types implement the entire lite interface, there is no problem with\nembedding regular types inside lite types. \n\nInheritance\n-----------\n\n[java.lang.Object](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html) \\\u003e ExtensionRegistryLite \n\nInherited Members\n-----------------\n\n[Object.clone()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#clone--) \n[Object.equals(Object)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#equals-java.lang.Object-) \n[Object.finalize()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#finalize--) \n[Object.getClass()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#getClass--) \n[Object.hashCode()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#hashCode--) \n[Object.notify()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notify--) \n[Object.notifyAll()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#notifyAll--) \n[Object.toString()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#toString--) \n[Object.wait()](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait--) \n[Object.wait(long)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-) \n[Object.wait(long,int)](https://docs.oracle.com/javase/8/docs/api/java/lang/Object.html#wait-long-int-)\n\nStatic Methods\n--------------\n\n### getEmptyRegistry()\n\n public static ExtensionRegistryLite getEmptyRegistry()\n\nGet the unmodifiable singleton empty instance of either ExtensionRegistryLite or `\nExtensionRegistry` (if the full (non-Lite) proto libraries are available).\n\n### isEagerlyParseMessageSets()\n\n public static boolean isEagerlyParseMessageSets()\n\n### newInstance()\n\n public static ExtensionRegistryLite newInstance()\n\nConstruct a new, empty instance.\n\nThis may be an `ExtensionRegistry` if the full (non-Lite) proto libraries are\navailable.\n\n### setEagerlyParseMessageSets(boolean isEagerlyParse)\n\n public static void setEagerlyParseMessageSets(boolean isEagerlyParse)\n\nMethods\n-------\n\n### \\\u003cContainingType\\\u003efindLiteExtensionByNumber(ContainingType containingTypeDefaultInstance, int fieldNumber)\n\n public GeneratedMessageLite.GeneratedExtension\u003cContainingType,?\u003e \u003cContainingType\u003efindLiteExtensionByNumber(ContainingType containingTypeDefaultInstance, int fieldNumber)\n\nFind an extension by containing type and field number.\n\n### add(ExtensionLite\\\u003c?,?\\\u003e extension)\n\n public final void add(ExtensionLite\u003c?,?\u003e extension)\n\nAdd an extension from a lite generated file to the registry only if it is a non-lite extension\ni.e. [GeneratedMessageLite.GeneratedExtension](/java/docs/reference/protobuf/latest/com.google.protobuf.GeneratedMessageLite.GeneratedExtension).\n\n### add(GeneratedMessageLite.GeneratedExtension\\\u003c?,?\\\u003e extension)\n\n public final void add(GeneratedMessageLite.GeneratedExtension\u003c?,?\u003e extension)\n\nAdd an extension from a lite generated file to the registry.\n\n### getUnmodifiable()\n\n public ExtensionRegistryLite getUnmodifiable()\n\nReturns an unmodifiable view of the registry."]]