From: Mark Slee Date: Wed, 13 Feb 2008 22:03:15 +0000 (+0000) Subject: Fix Java generator for javabean target to construct maps and lists properly X-Git-Tag: 0.2.0~996 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=dd43eb85c767118c89137dc5ac5b9f29f2cc80f6;p=common%2Fthrift.git Fix Java generator for javabean target to construct maps and lists properly Summary: From Johann Oskarsson Reviewed By: dreiss Test Plan: Generate javabean code git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665476 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 0440222c..ea91f662 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -188,7 +188,7 @@ void t_java_generator::print_const_value(std::ofstream& out, string name, t_type vector::const_iterator f_iter; const map& val = value->get_map(); map::const_iterator v_iter; - out << name << " = new " << type_name(type) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << endl; if (!in_static) { indent(out) << "static {" << endl; indent_up(); @@ -213,7 +213,7 @@ void t_java_generator::print_const_value(std::ofstream& out, string name, t_type } out << endl; } else if (type->is_map()) { - out << name << " = new " << type_name(type, true, true) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << endl; if (!in_static) { indent(out) << "static {" << endl; indent_up(); @@ -233,7 +233,7 @@ void t_java_generator::print_const_value(std::ofstream& out, string name, t_type } out << endl; } else if (type->is_list() || type->is_set()) { - out << name << " = new " << type_name(type) << "();" << endl; + out << name << " = new " << type_name(type, false, true) << "();" << endl; if (!in_static) { indent(out) << "static {" << endl; indent_up(); @@ -739,7 +739,7 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, indent_up(); indent(out) << "if (this." << field_name << " == null) {" << endl; indent_up(); - indent(out) << "this." << field_name << " = new " << type_name(type) << + indent(out) << "this." << field_name << " = new " << type_name(type, false, true) << "();" << endl; indent_down(); indent(out) << "}" << endl;