diff --git a/src/google/protobuf/compiler/java/file.cc b/src/google/protobuf/compiler/java/file.cc index 58e66e8cab..cac9fc4f59 100644 --- a/src/google/protobuf/compiler/java/file.cc +++ b/src/google/protobuf/compiler/java/file.cc @@ -424,6 +424,10 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable( "_clinit_autosplit_dinit_$method_num$();\n", "private static void _clinit_autosplit_dinit_$method_num$() {\n"); } + // Feature resolution for Java features uses extension registry + // which must happen after internalInit() from + // GenerateNonNestedInitializationCode + printer->Print("descriptor.resolveAllFeatures();\n"); // Proto compiler builds a DescriptorPool, which holds all the descriptors to // generate, when processing the ".proto" files. We call this DescriptorPool diff --git a/src/google/protobuf/compiler/java/shared_code_generator.cc b/src/google/protobuf/compiler/java/shared_code_generator.cc index ee837955d7..366e8d7963 100644 --- a/src/google/protobuf/compiler/java/shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/shared_code_generator.cc @@ -86,6 +86,7 @@ void SharedCodeGenerator::Generate( " * an incomplete descriptor for internal use only. */\n" " public static com.google.protobuf.Descriptors.FileDescriptor " "getDescriptor() {\n" + " descriptor.resolveAllFeatures();\n" " return descriptor;\n" " }\n" " static {\n",