Internal changes/optimizations

PiperOrigin-RevId: 635516715
pull/16858/head
Protobuf Team Bot 8 months ago committed by Copybara-Service
parent 858a2ab52f
commit fa4bab26e4
  1. 3
      java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java
  2. 3
      java/core/src/main/java/com/google/protobuf/ExtensionSchemas.java
  3. 3
      java/core/src/main/java/com/google/protobuf/ListFieldSchemas.java
  4. 3
      java/core/src/main/java/com/google/protobuf/MapFieldSchemas.java
  5. 3
      java/core/src/main/java/com/google/protobuf/NewInstanceSchemas.java
  6. 7
      java/core/src/main/java/com/google/protobuf/SchemaUtil.java

@ -48,7 +48,8 @@ final class ExtensionRegistryFactory {
}
static boolean isFullRegistry(ExtensionRegistryLite registry) {
return EXTENSION_REGISTRY_CLASS != null
return !Protobuf.assumeLiteRuntime
&& EXTENSION_REGISTRY_CLASS != null
&& EXTENSION_REGISTRY_CLASS.isAssignableFrom(registry.getClass());
}

@ -13,6 +13,9 @@ final class ExtensionSchemas {
private static final ExtensionSchema<?> FULL_SCHEMA = loadSchemaForFullRuntime();
private static ExtensionSchema<?> loadSchemaForFullRuntime() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
Class<?> clazz = Class.forName("com.google.protobuf.ExtensionSchemaFull");
return (ExtensionSchema) clazz.getDeclaredConstructor().newInstance();

@ -21,6 +21,9 @@ final class ListFieldSchemas {
}
private static ListFieldSchema loadSchemaForFullRuntime() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
Class<?> clazz = Class.forName("com.google.protobuf.ListFieldSchemaFull");
return (ListFieldSchema) clazz.getDeclaredConstructor().newInstance();

@ -21,6 +21,9 @@ final class MapFieldSchemas {
}
private static MapFieldSchema loadSchemaForFullRuntime() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
Class<?> clazz = Class.forName("com.google.protobuf.MapFieldSchemaFull");
return (MapFieldSchema) clazz.getDeclaredConstructor().newInstance();

@ -21,6 +21,9 @@ final class NewInstanceSchemas {
}
private static NewInstanceSchema loadSchemaForFullRuntime() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
Class<?> clazz = Class.forName("com.google.protobuf.NewInstanceSchemaFull");
return (NewInstanceSchema) clazz.getDeclaredConstructor().newInstance();

@ -38,6 +38,7 @@ final class SchemaUtil {
// TODO decide if we're keeping support for Full in schema classes and handle this
// better.
if (!GeneratedMessageLite.class.isAssignableFrom(messageType)
&& !Protobuf.assumeLiteRuntime
&& GENERATED_MESSAGE_CLASS != null
&& !GENERATED_MESSAGE_CLASS.isAssignableFrom(messageType)) {
throw new IllegalArgumentException(
@ -781,6 +782,9 @@ final class SchemaUtil {
}
private static Class<?> getGeneratedMessageClass() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
// TODO decide if we're keeping support for Full in schema classes and handle
// this better.
@ -791,6 +795,9 @@ final class SchemaUtil {
}
private static Class<?> getUnknownFieldSetSchemaClass() {
if (Protobuf.assumeLiteRuntime) {
return null;
}
try {
return Class.forName("com.google.protobuf.UnknownFieldSetSchema");
} catch (Throwable e) {

Loading…
Cancel
Save