aboutsummaryrefslogtreecommitdiff
path: root/src/google/protobuf/compiler/java/java_enum.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/google/protobuf/compiler/java/java_enum.cc')
-rw-r--r--src/google/protobuf/compiler/java/java_enum.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/google/protobuf/compiler/java/java_enum.cc b/src/google/protobuf/compiler/java/java_enum.cc
index 26cd76c9..9eea873a 100644
--- a/src/google/protobuf/compiler/java/java_enum.cc
+++ b/src/google/protobuf/compiler/java/java_enum.cc
@@ -64,6 +64,7 @@ EnumGenerator::EnumGenerator(const EnumDescriptor* descriptor,
bool immutable_api,
Context* context)
: descriptor_(descriptor), immutable_api_(immutable_api),
+ context_(context),
name_resolver_(context->GetNameResolver()) {
for (int i = 0; i < descriptor_->value_count(); i++) {
const EnumValueDescriptor* value = descriptor_->value(i);
@@ -150,6 +151,10 @@ void EnumGenerator::Generate(io::Printer* printer) {
" return value;\n"
"}\n"
"\n"
+ "/**\n"
+ " * @deprecated Use {@link #forNumber(int)} instead.\n"
+ " */\n"
+ "@java.lang.Deprecated\n"
"public static $classname$ valueOf(int value) {\n"
" return forNumber(value);\n"
"}\n"
@@ -191,7 +196,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
// -----------------------------------------------------------------
// Reflection
- if (HasDescriptorMethods(descriptor_)) {
+ if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {
printer->Print(
"public final com.google.protobuf.Descriptors.EnumValueDescriptor\n"
" getValueDescriptor() {\n"
@@ -233,7 +238,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
" (com.google.protobuf.Descriptors.FileDescriptor)\n"
" m.invoke(immutableFileClass);\n"
" return file.getEnumTypes().get($index$);\n"
- "} catch (Exception e) {\n"
+ "} catch (java.lang.Exception e) {\n"
// Immutable classes cannot be found. Proceed as if custom options
// don't exist.
"}\n",
@@ -317,7 +322,7 @@ void EnumGenerator::Generate(io::Printer* printer) {
"private final int value;\n\n"
"private $classname$(int index, int value) {\n",
"classname", descriptor_->name());
- if (HasDescriptorMethods(descriptor_)) {
+ if (HasDescriptorMethods(descriptor_, context_->EnforceLite())) {
printer->Print(" this.index = index;\n");
}
printer->Print(