Change java descriptor back to private

pull/1/head
jieluo@google.com 10 years ago
parent 83964a9ab4
commit d7339318a3
  1. 2
      src/google/protobuf/compiler/java/java_enum.cc
  2. 2
      src/google/protobuf/compiler/java/java_file.cc
  3. 26
      src/google/protobuf/compiler/java/java_shared_code_generator.cc

@ -231,7 +231,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
"index", SimpleItoa(descriptor_->index())); "index", SimpleItoa(descriptor_->index()));
} }
printer->Print( printer->Print(
"return $immutable_package$.$descriptor_class$.descriptor\n" "return $immutable_package$.$descriptor_class$.getDescriptor()\n"
" .getEnumTypes().get($index$);\n", " .getEnumTypes().get($index$);\n",
"immutable_package", FileJavaPackage(descriptor_->file(), true), "immutable_package", FileJavaPackage(descriptor_->file(), true),
"descriptor_class", "descriptor_class",

@ -315,7 +315,7 @@ void FileGenerator::GenerateDescriptorInitializationCodeForImmutable(
" getDescriptor() {\n" " getDescriptor() {\n"
" return descriptor;\n" " return descriptor;\n"
"}\n" "}\n"
"public static com.google.protobuf.Descriptors.FileDescriptor\n" "private static com.google.protobuf.Descriptors.FileDescriptor\n"
" descriptor;\n" " descriptor;\n"
"static {\n"); "static {\n");
printer->Indent(); printer->Indent();

@ -176,36 +176,16 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) {
// Invoke internalBuildGeneratedFileFrom() to build the file. // Invoke internalBuildGeneratedFileFrom() to build the file.
printer->Print( printer->Print(
"com.google.protobuf.Descriptors.FileDescriptor\n" "com.google.protobuf.Descriptors.FileDescriptor\n"
" .internalBuildGeneratedFileFrom(descriptorData,\n"); " .internalBuildGeneratedFileFrom(descriptorData,\n"
" new com.google.protobuf.Descriptors.FileDescriptor[] {\n");
printer->Print(
" $classname$.class,\n"
" new java.lang.String[] {\n",
"classname", name_resolver_->GetDescriptorClassName(file_));
for (int i = 0; i < dependencies.size(); i++) { for (int i = 0; i < dependencies.size(); i++) {
const string& dependency = dependencies[i].second; const string& dependency = dependencies[i].second;
printer->Print( printer->Print(
// Here we load the dependency FileDescriptors lazily via Java " $dependency$.getDescriptor(),\n",
// reflection. This is to avoid breaking proto1 targets who have
// genproto dependencies for which we can't generate the descriptor
// class. They will compile fine but when users try to call reflection
// functions upon them it will fail. Users will have to get rid of
// genproto dependencies before they can use proto2 reflection on
// proto1 messages.
" \"$dependency$\",\n",
"dependency", dependency); "dependency", dependency);
} }
printer->Print(
" }, new java.lang.String[] {\n");
for (int i = 0; i < dependencies.size(); i++) {
const string& filename = dependencies[i].first;
printer->Print(
" \"$filename$\",\n",
"filename", filename);
}
printer->Print( printer->Print(
" }, assigner);\n"); " }, assigner);\n");
} }

Loading…
Cancel
Save