Commit e9c15d60 authored by Adam Cozzette's avatar Adam Cozzette

Ensure that for Java, imports of .proto files with empty packages works

This fixes a compiler bug that caused a Java syntax error when one .proto file
would import another one with an empty package and java_package. This fixes
issue #3114.
parent d6470abe
......@@ -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));
}
// -----------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment