|
|
|
@ -53,10 +53,6 @@ public class ExtensionRegistryLite { |
|
|
|
|
// applications. Need to support this feature on smaller granularity.
|
|
|
|
|
private static volatile boolean eagerlyParseMessageSets = false; |
|
|
|
|
|
|
|
|
|
// short circuit the ExtensionRegistryFactory via assumevalues trickery
|
|
|
|
|
@SuppressWarnings("JavaOptionalSuggestions") |
|
|
|
|
private static boolean doFullRuntimeInheritanceCheck = true; |
|
|
|
|
|
|
|
|
|
// Visible for testing.
|
|
|
|
|
static final String EXTENSION_CLASS_NAME = "com.google.protobuf.Extension"; |
|
|
|
|
|
|
|
|
@ -88,9 +84,9 @@ public class ExtensionRegistryLite { |
|
|
|
|
* available. |
|
|
|
|
*/ |
|
|
|
|
public static ExtensionRegistryLite newInstance() { |
|
|
|
|
return doFullRuntimeInheritanceCheck |
|
|
|
|
? ExtensionRegistryFactory.create() |
|
|
|
|
: new ExtensionRegistryLite(); |
|
|
|
|
return Protobuf.assumeLiteRuntime |
|
|
|
|
? new ExtensionRegistryLite() |
|
|
|
|
: ExtensionRegistryFactory.create(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static volatile ExtensionRegistryLite emptyRegistry; |
|
|
|
@ -100,7 +96,7 @@ public class ExtensionRegistryLite { |
|
|
|
|
* ExtensionRegistry} (if the full (non-Lite) proto libraries are available). |
|
|
|
|
*/ |
|
|
|
|
public static ExtensionRegistryLite getEmptyRegistry() { |
|
|
|
|
if (!doFullRuntimeInheritanceCheck) { |
|
|
|
|
if (Protobuf.assumeLiteRuntime) { |
|
|
|
|
return EMPTY_REGISTRY_LITE; |
|
|
|
|
} |
|
|
|
|
ExtensionRegistryLite result = emptyRegistry; |
|
|
|
@ -148,7 +144,7 @@ public class ExtensionRegistryLite { |
|
|
|
|
if (GeneratedMessageLite.GeneratedExtension.class.isAssignableFrom(extension.getClass())) { |
|
|
|
|
add((GeneratedMessageLite.GeneratedExtension<?, ?>) extension); |
|
|
|
|
} |
|
|
|
|
if (doFullRuntimeInheritanceCheck && ExtensionRegistryFactory.isFullRegistry(this)) { |
|
|
|
|
if (!Protobuf.assumeLiteRuntime && ExtensionRegistryFactory.isFullRegistry(this)) { |
|
|
|
|
try { |
|
|
|
|
this.getClass().getMethod("add", ExtensionClassHolder.INSTANCE).invoke(this, extension); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|