Index: third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc |
index e796587f4e927bb1437b412e1eb933e4193dff5d..9d7bcab64f1345778aced6017b0cec04e9c69845 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_enum.cc |
@@ -104,6 +104,15 @@ void EnumGenerator::Generate(io::Printer* printer) { |
"public static final $classname$ $name$ = $canonical_name$;\n"); |
} |
+ for (int i = 0; i < descriptor_->value_count(); i++) { |
+ map<string, string> vars; |
+ vars["name"] = descriptor_->value(i)->name(); |
+ vars["number"] = SimpleItoa(descriptor_->value(i)->number()); |
+ printer->Print(vars, |
+ "public static final int $name$_VALUE = $number$;\n"); |
+ } |
+ printer->Print("\n"); |
+ |
// ----------------------------------------------------------------- |
printer->Print( |
@@ -219,17 +228,6 @@ void EnumGenerator::Generate(io::Printer* printer) { |
" this.value = value;\n" |
"}\n"); |
- if (HasDescriptorMethods(descriptor_)) { |
- // Force the static initialization code for the file to run, since it may |
- // initialize static variables declared in this class. |
- printer->Print( |
- "\n" |
- "static {\n" |
- " $file$.getDescriptor();\n" |
- "}\n", |
- "file", ClassName(descriptor_->file())); |
- } |
- |
printer->Print( |
"\n" |
"// @@protoc_insertion_point(enum_scope:$full_name$)\n", |