aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/java/java_extension.cc
diff options
context:
space:
mode:
authorGravatar Daniel Martin <fizbin@gmail.com>2014-11-25 10:37:57 -0500
committerGravatar Daniel Martin <daniel.martin@crowdstrike.com>2014-11-25 12:45:17 -0500
commite2416caf906a680a27bd89a91f14b2cdcaaa1634 (patch)
treecd6b982cca9a8de3e2a78bd3cd06f4abdf71c20a /src/google/protobuf/compiler/java/java_extension.cc
parent99aa0f9e8f1a88def7bdebf1385678559cda0707 (diff)
Fix java compilation issues when processing large .proto files
Fix issues 579 and 501 on the code.google.com issues list. Specifically, large .proto files lead to too much static code, leading to a compilation error from javac: "code too large". This divides the code used in static initialization into multiple methods to avoid that error. Also, this incorporates the fix in issue 501 on the code.google.com issues list to call registry.add only once per extension.
Diffstat (limited to 'src/google/protobuf/compiler/java/java_extension.cc')
-rw-r--r--src/google/protobuf/compiler/java/java_extension.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/java/java_extension.cc b/src/google/protobuf/compiler/java/java_extension.cc
index 27cf416b..4db7085e 100644
--- a/src/google/protobuf/compiler/java/java_extension.cc
+++ b/src/google/protobuf/compiler/java/java_extension.cc
@@ -181,8 +181,9 @@ void ImmutableExtensionGenerator::Generate(io::Printer* printer) {
}
}
-void ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
+int ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
io::Printer* printer) {
+ int bytecode_estimate = 0;
if (descriptor_->extension_scope() == NULL &&
HasDescriptorMethods(descriptor_->file())) {
// Only applies to non-nested, non-lite extensions.
@@ -190,15 +191,18 @@ void ImmutableExtensionGenerator::GenerateNonNestedInitializationCode(
"$name$.internalInit(descriptor.getExtensions().get($index$));\n",
"name", UnderscoresToCamelCase(descriptor_),
"index", SimpleItoa(descriptor_->index()));
+ bytecode_estimate += 21;
}
+ return bytecode_estimate;
}
-void ImmutableExtensionGenerator::GenerateRegistrationCode(
+int ImmutableExtensionGenerator::GenerateRegistrationCode(
io::Printer* printer) {
printer->Print(
"registry.add($scope$.$name$);\n",
"scope", scope_,
"name", UnderscoresToCamelCase(descriptor_));
+ return 7;
}
} // namespace java