diff options
author | Adam Cozzette <acozzette@gmail.com> | 2017-06-07 15:15:34 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-07 15:15:34 -0700 |
commit | 96095f3a8577cd61ded2191d267cca70f221a9c9 (patch) | |
tree | dd206a2381c8db66967d1afa43674aee45f080f9 | |
parent | c202b06de9501509171de58d90019a86f2aa5311 (diff) | |
parent | e9c15d601e1f424d4e2c2b004b00cd6efd394d3e (diff) |
Merge pull request #3176 from acozzette/fix-3114
Ensure that for Java, imports of .proto files with empty packages works
-rw-r--r-- | src/google/protobuf/compiler/java/java_shared_code_generator.cc | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/google/protobuf/compiler/java/java_shared_code_generator.cc b/src/google/protobuf/compiler/java/java_shared_code_generator.cc index 7bd5ad7a..f73bfb04 100644 --- a/src/google/protobuf/compiler/java/java_shared_code_generator.cc +++ b/src/google/protobuf/compiler/java/java_shared_code_generator.cc @@ -182,10 +182,16 @@ void SharedCodeGenerator::GenerateDescriptors(io::Printer* printer) { std::vector<std::pair<string, string> > dependencies; for (int i = 0; i < file_->dependency_count(); i++) { string filename = file_->dependency(i)->name(); - string classname = FileJavaPackage(file_->dependency(i)) + "." + - name_resolver_->GetDescriptorClassName( - file_->dependency(i)); - dependencies.push_back(std::make_pair(filename, classname)); + string package = FileJavaPackage(file_->dependency(i)); + string classname = name_resolver_->GetDescriptorClassName( + file_->dependency(i)); + string full_name; + if (package.empty()) { + full_name = classname; + } else { + full_name = package + "." + classname; + } + dependencies.push_back(std::make_pair(filename, full_name)); } // ----------------------------------------------------------------- |