You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/04/02 23:21:58 UTC

git commit: THRIFT-2435 Java compiler doesn't like struct member names that are identical to an existing enum or struct type Client: java Patch: Jens Geyer

Repository: thrift
Updated Branches:
  refs/heads/master 7f76e1d9f -> d06957bf9


THRIFT-2435 Java compiler doesn't like struct member names that are identical to an existing enum or struct type
Client: java
Patch: Jens Geyer


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/d06957bf
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/d06957bf
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/d06957bf

Branch: refs/heads/master
Commit: d06957bf914a025fbf65d7625e1edc78c4bc11ef
Parents: 7f76e1d
Author: Jens Geyer <je...@apache.org>
Authored: Wed Apr 2 23:21:25 2014 +0200
Committer: Jens Geyer <je...@apache.org>
Committed: Wed Apr 2 23:21:25 2014 +0200

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_java_generator.cc | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/d06957bf/compiler/cpp/src/generate/t_java_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc
index 9019c48..9c6b4a5 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -270,7 +270,7 @@ public:
   std::string java_package();
   std::string java_type_imports();
   std::string java_suppressions();
-  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false);
+  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false, bool force_namespace = false);
   std::string base_type_name(t_base_type* tbase, bool in_container=false);
   std::string declare_field(t_field* tfield, bool init=false, bool comment=false);
   std::string function_signature(t_function* tfunction, std::string prefix="");
@@ -3073,7 +3073,7 @@ void t_java_generator::generate_deserialize_field(ofstream& out,
     }
     out << endl;
   } else if (type->is_enum()) {
-    indent(out) << name << " = " << type_name(tfield->get_type(), true, false) + ".findByValue(iprot.readI32());" << endl;
+    indent(out) << name << " = " << type_name(tfield->get_type(), true, false, false, true) + ".findByValue(iprot.readI32());" << endl;
   } else {
     printf("DO NOT KNOW HOW TO DESERIALIZE FIELD '%s' TYPE '%s'\n",
            tfield->get_name().c_str(), type_name(type).c_str());
@@ -3481,7 +3481,7 @@ void t_java_generator::generate_serialize_list_element(ofstream& out,
  * @param container Is the type going inside a container?
  * @return Java type name, i.e. HashMap<Key,Value>
  */
-string t_java_generator::type_name(t_type* ttype, bool in_container, bool in_init, bool skip_generic) {
+string t_java_generator::type_name(t_type* ttype, bool in_container, bool in_init, bool skip_generic, bool force_namespace) {
   // In Java typedefs are just resolved to their real type
   ttype = get_true_type(ttype);
   string prefix;
@@ -3526,7 +3526,7 @@ string t_java_generator::type_name(t_type* ttype, bool in_container, bool in_ini
 
   // Check for namespacing
   t_program* program = ttype->get_program();
-  if (program != NULL && program != program_) {
+  if ((program != NULL && program != program_) || force_namespace) {
     string package = program->get_namespace("java");
     if (!package.empty()) {
       return package + "." + ttype->get_name();