THRIFT-1251. java: Generated java code should indicate which fields are required and which are optional

Patch: Takashi Yonebayashi

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1153302 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 1b55172..f9ed5e2 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -3329,7 +3329,13 @@
       result += " = new " + type_name(ttype, false, true) + "()";;
     }
   }
-  return result + ";";
+  result += "; // ";
+  if (tfield->get_xsd_optional()) {
+    result += "optional";
+  } else {
+    result += "required";
+  }
+  return result;
 }
 
 /**