From 932ce2b80ab604fff2a5ea489fe507a821074425 Mon Sep 17 00:00:00 2001 From: Bryan Duxbury Date: Tue, 7 Dec 2010 18:28:48 +0000 Subject: [PATCH] THRIFT-1013. java: generated java code may have name clashes with thrift library This patch removes the imports for Thrift library classes and fully qualifies all references, guaranteeing there won't be any name clashes. Patch: Peter Schuller git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1043156 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/src/generate/t_java_generator.cc | 287 ++++++++---------- 1 file changed, 134 insertions(+), 153 deletions(-) diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc index fca576ee..0e25e60b 100644 --- a/compiler/cpp/src/generate/t_java_generator.cc +++ b/compiler/cpp/src/generate/t_java_generator.cc @@ -215,7 +215,6 @@ class t_java_generator : public t_oop_generator { std::string java_package(); std::string java_type_imports(); - std::string java_thrift_imports(); std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false, bool skip_generic=false); std::string base_type_name(t_base_type* tbase, bool in_container=false); std::string declare_field(t_field* tfield, bool init=false); @@ -330,21 +329,6 @@ string t_java_generator::java_type_imports() { "import org.slf4j.LoggerFactory;\n\n"; } -/** - * Prints standard java imports - * - * @return List of imports necessary for thrift - */ -string t_java_generator::java_thrift_imports() { - return - string() + - "import org.apache.thrift.*;\n" + - "import org.apache.thrift.async.*;\n" + - "import org.apache.thrift.meta_data.*;\n" + - "import org.apache.thrift.transport.*;\n" + - "import org.apache.thrift.protocol.*;\n\n"; -} - /** * Nothing in Java */ @@ -385,7 +369,7 @@ void t_java_generator::generate_enum(t_enum* tenum) { generate_java_doc(f_enum, tenum); indent(f_enum) << - "public enum " << tenum->get_name() << " implements TEnum "; + "public enum " << tenum->get_name() << " implements org.apache.thrift.TEnum "; scope_up(f_enum); vector constants = tenum->get_constants(); @@ -635,7 +619,7 @@ string t_java_generator::render_const_value(ofstream& out, string name, t_type* } /** - * Generates a struct definition for a thrift data type. This will be a TBase + * Generates a struct definition for a thrift data type. This will be a org.apache.thrift.TBase * implementor. * * @param tstruct The struct definition @@ -673,8 +657,7 @@ void t_java_generator::generate_java_struct(t_struct* tstruct, f_struct << autogen_comment() << java_package() << - java_type_imports() << - java_thrift_imports(); + java_type_imports(); generate_java_struct_definition(f_struct, tstruct, @@ -696,8 +679,7 @@ void t_java_generator::generate_java_union(t_struct* tstruct) { f_struct << autogen_comment() << java_package() << - java_type_imports() << - java_thrift_imports(); + java_type_imports(); generate_java_doc(f_struct, tstruct); @@ -705,7 +687,7 @@ void t_java_generator::generate_java_union(t_struct* tstruct) { indent(f_struct) << "public " << (is_final ? "final " : "") << "class " << tstruct->get_name() - << " extends TUnion<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields> "; + << " extends org.apache.thrift.TUnion<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields> "; scope_up(f_struct); @@ -806,7 +788,7 @@ void t_java_generator::generate_union_getters_and_setters(ofstream& out, t_struc generate_java_doc(out, field); if (type->is_base_type() && ((t_base_type*)type)->is_binary()) { indent(out) << "public byte[] get" << cap_name << "() {" << endl; - indent(out) << " set" << cap_name << "(TBaseHelper.rightSize(buffer" << get_cap_name("for") << cap_name << "()));" << endl; + indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(buffer" << get_cap_name("for") << cap_name << "()));" << endl; indent(out) << " ByteBuffer b = buffer" << get_cap_name("for") << cap_name << "();" << endl; indent(out) << " return b == null ? null : b.array();" << endl; indent(out) << "}" << endl; @@ -905,7 +887,7 @@ void t_java_generator::generate_check_type(ofstream& out, t_struct* tstruct) { void t_java_generator::generate_read_value(ofstream& out, t_struct* tstruct) { indent(out) << "@Override" << endl; - indent(out) << "protected Object readValue(TProtocol iprot, TField field) throws TException {" << endl; + indent(out) << "protected Object readValue(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TField field) throws org.apache.thrift.TException {" << endl; indent_up(); @@ -930,7 +912,7 @@ void t_java_generator::generate_read_value(ofstream& out, t_struct* tstruct) { indent(out) << "return " << field->get_name() << ";" << endl; indent_down(); indent(out) << "} else {" << endl; - indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl; + indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl; indent(out) << " return null;" << endl; indent(out) << "}" << endl; indent_down(); @@ -945,7 +927,7 @@ void t_java_generator::generate_read_value(ofstream& out, t_struct* tstruct) { indent_down(); indent(out) << "} else {" << endl; indent_up(); - indent(out) << "TProtocolUtil.skip(iprot, field.type);" << endl; + indent(out) << "org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl; indent(out) << "return null;" << endl; indent_down(); indent(out) << "}" << endl; @@ -956,7 +938,7 @@ void t_java_generator::generate_read_value(ofstream& out, t_struct* tstruct) { void t_java_generator::generate_write_value(ofstream& out, t_struct* tstruct) { indent(out) << "@Override" << endl; - indent(out) << "protected void writeValue(TProtocol oprot) throws TException {" << endl; + indent(out) << "protected void writeValue(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl; indent_up(); @@ -993,7 +975,7 @@ void t_java_generator::generate_write_value(ofstream& out, t_struct* tstruct) { void t_java_generator::generate_get_field_desc(ofstream& out, t_struct* tstruct) { indent(out) << "@Override" << endl; - indent(out) << "protected TField getFieldDesc(_Fields setField) {" << endl; + indent(out) << "protected org.apache.thrift.protocol.TField getFieldDesc(_Fields setField) {" << endl; indent_up(); const vector& members = tstruct->get_members(); @@ -1021,7 +1003,7 @@ void t_java_generator::generate_get_field_desc(ofstream& out, t_struct* tstruct) void t_java_generator::generate_get_struct_desc(ofstream& out, t_struct* tstruct) { (void) tstruct; indent(out) << "@Override" << endl; - indent(out) << "protected TStruct getStructDesc() {" << endl; + indent(out) << "protected org.apache.thrift.protocol.TStruct getStructDesc() {" << endl; indent(out) << " return STRUCT_DESC;" << endl; indent(out) << "}" << endl; } @@ -1045,9 +1027,9 @@ void t_java_generator::generate_union_comparisons(ofstream& out, t_struct* tstru indent(out) << "@Override" << endl; indent(out) << "public int compareTo(" << type_name(tstruct) << " other) {" << endl; - indent(out) << " int lastComparison = TBaseHelper.compareTo(getSetField(), other.getSetField());" << endl; + indent(out) << " int lastComparison = org.apache.thrift.TBaseHelper.compareTo(getSetField(), other.getSetField());" << endl; indent(out) << " if (lastComparison == 0) {" << endl; - indent(out) << " return TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" << endl; + indent(out) << " return org.apache.thrift.TBaseHelper.compareTo(getFieldValue(), other.getFieldValue());" << endl; indent(out) << " }" << endl; indent(out) << " return lastComparison;" << endl; indent(out) << "}" << endl; @@ -1061,12 +1043,12 @@ void t_java_generator::generate_union_hashcode(ofstream& out, t_struct* tstruct) indent(out) << "public int hashCode() {" << endl; indent(out) << " HashCodeBuilder hcb = new HashCodeBuilder();" << endl; indent(out) << " hcb.append(this.getClass().getName());" << endl; - indent(out) << " TFieldIdEnum setField = getSetField();" << endl; + indent(out) << " org.apache.thrift.TFieldIdEnum setField = getSetField();" << endl; indent(out) << " if (setField != null) {" << endl; indent(out) << " hcb.append(setField.getThriftFieldId());" << endl; indent(out) << " Object value = getFieldValue();" << endl; - indent(out) << " if (value instanceof TEnum) {" << endl; - indent(out) << " hcb.append(((TEnum)getFieldValue()).getValue());" << endl; + indent(out) << " if (value instanceof org.apache.thrift.TEnum) {" << endl; + indent(out) << " hcb.append(((org.apache.thrift.TEnum)getFieldValue()).getValue());" << endl; indent(out) << " } else {" << endl; indent(out) << " hcb.append(value);" << endl; indent(out) << " }" << endl; @@ -1110,7 +1092,7 @@ void t_java_generator::generate_java_struct_definition(ofstream &out, if (is_exception) { out << "extends Exception "; } - out << "implements TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable"; + out << "implements org.apache.thrift.TBase<" << tstruct->get_name() << ", " << tstruct->get_name() << "._Fields>, java.io.Serializable, Cloneable"; out << " "; @@ -1425,7 +1407,7 @@ void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct* indent(out) << "}" << endl; indent(out) << "if (" << generate_isset_check(field) << ") {" << endl; - indent(out) << " lastComparison = TBaseHelper.compareTo(this." << field->get_name() << ", typedOther." << field->get_name() << ");" << endl; + indent(out) << " lastComparison = org.apache.thrift.TBaseHelper.compareTo(this." << field->get_name() << ", typedOther." << field->get_name() << ");" << endl; indent(out) << " if (lastComparison != 0) {" << endl; indent(out) << " return lastComparison;" << endl; indent(out) << " }" << endl; @@ -1446,7 +1428,7 @@ void t_java_generator::generate_java_struct_compare_to(ofstream& out, t_struct* void t_java_generator::generate_java_struct_reader(ofstream& out, t_struct* tstruct) { out << - indent() << "public void read(TProtocol iprot) throws TException {" << endl; + indent() << "public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {" << endl; indent_up(); const vector& fields = tstruct->get_members(); @@ -1454,7 +1436,7 @@ void t_java_generator::generate_java_struct_reader(ofstream& out, // Declare stack tmp variables and read struct header out << - indent() << "TField field;" << endl << + indent() << "org.apache.thrift.protocol.TField field;" << endl << indent() << "iprot.readStructBegin();" << endl; // Loop over reading in fields @@ -1468,7 +1450,7 @@ void t_java_generator::generate_java_struct_reader(ofstream& out, // Check for field STOP marker and break indent(out) << - "if (field.type == TType.STOP) { " << endl; + "if (field.type == org.apache.thrift.protocol.TType.STOP) { " << endl; indent_up(); indent(out) << "break;" << endl; @@ -1495,14 +1477,14 @@ void t_java_generator::generate_java_struct_reader(ofstream& out, indent_down(); out << indent() << "} else { " << endl << - indent() << " TProtocolUtil.skip(iprot, field.type);" << endl << + indent() << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl << indent() << "}" << endl << indent() << "break;" << endl; indent_down(); } indent(out) << "default:" << endl; - indent(out) << " TProtocolUtil.skip(iprot, field.type);" << endl; + indent(out) << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type);" << endl; indent_down(); indent(out) << "}" << endl; @@ -1525,7 +1507,7 @@ void t_java_generator::generate_java_struct_reader(ofstream& out, if ((*f_iter)->get_req() == t_field::T_REQUIRED && !type_can_be_null((*f_iter)->get_type())) { out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << - indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl << + indent() << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not found in serialized data! Struct: \" + toString());" << endl << indent() << "}" << endl; } } @@ -1544,7 +1526,7 @@ void t_java_generator::generate_java_struct_reader(ofstream& out, // (e.g. check that all required fields are set) void t_java_generator::generate_java_validator(ofstream& out, t_struct* tstruct){ - indent(out) << "public void validate() throws TException {" << endl; + indent(out) << "public void validate() throws org.apache.thrift.TException {" << endl; indent_up(); const vector& fields = tstruct->get_members(); @@ -1556,12 +1538,12 @@ void t_java_generator::generate_java_validator(ofstream& out, if (bean_style_) { out << indent() << "if (!" << generate_isset_check(*f_iter) << ") {" << endl << - indent() << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl << + indent() << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' is unset! Struct:\" + toString());" << endl << indent() << "}" << endl << endl; } else{ if (type_can_be_null((*f_iter)->get_type())) { indent(out) << "if (" << (*f_iter)->get_name() << " == null) {" << endl; - indent(out) << " throw new TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl; + indent(out) << " throw new org.apache.thrift.protocol.TProtocolException(\"Required field '" << (*f_iter)->get_name() << "' was not present! Struct: \" + toString());" << endl; indent(out) << "}" << endl; } else { indent(out) << "// alas, we cannot check '" << (*f_iter)->get_name() << "' because it's a primitive and you chose the non-beans generator." << endl; @@ -1582,7 +1564,7 @@ void t_java_generator::generate_java_validator(ofstream& out, void t_java_generator::generate_java_struct_writer(ofstream& out, t_struct* tstruct) { out << - indent() << "public void write(TProtocol oprot) throws TException {" << endl; + indent() << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl; indent_up(); string name = tstruct->get_name(); @@ -1647,7 +1629,7 @@ void t_java_generator::generate_java_struct_writer(ofstream& out, void t_java_generator::generate_java_struct_result_writer(ofstream& out, t_struct* tstruct) { out << - indent() << "public void write(TProtocol oprot) throws TException {" << endl; + indent() << "public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {" << endl; indent_up(); string name = tstruct->get_name(); @@ -1889,7 +1871,7 @@ void t_java_generator::generate_java_bean_boilerplate(ofstream& out, generate_java_doc(out, field); if (type->is_base_type() && ((t_base_type*)type)->is_binary()) { indent(out) << "public byte[] get" << cap_name << "() {" << endl; - indent(out) << " set" << cap_name << "(TBaseHelper.rightSize(" << field_name << "));" << endl; + indent(out) << " set" << cap_name << "(org.apache.thrift.TBaseHelper.rightSize(" << field_name << "));" << endl; indent(out) << " return " << field_name << " == null ? null : " << field_name << ".array();" << endl; indent(out) << "}" << endl << endl; @@ -2022,7 +2004,7 @@ void t_java_generator::generate_java_struct_tostring(ofstream& out, } if (field->get_type()->is_base_type() && ((t_base_type*)(field->get_type()))->is_binary()) { - indent(out) << "TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; + indent(out) << "org.apache.thrift.TBaseHelper.toString(this." << field->get_name() << ", sb);" << endl; } else { indent(out) << "sb.append(this." << (*f_iter)->get_name() << ");" << endl; } @@ -2059,26 +2041,26 @@ void t_java_generator::generate_java_meta_data_map(ofstream& out, const vector& fields = tstruct->get_members(); vector::const_iterator f_iter; - // Static Map with fieldID -> FieldMetaData mappings - indent(out) << "public static final Map<_Fields, FieldMetaData> metaDataMap;" << endl; + // Static Map with fieldID -> org.apache.thrift.meta_data.FieldMetaData mappings + indent(out) << "public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;" << endl; indent(out) << "static {" << endl; indent_up(); - indent(out) << "Map<_Fields, FieldMetaData> tmpMap = new EnumMap<_Fields, FieldMetaData>(_Fields.class);" << endl; + indent(out) << "Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);" << endl; // Populate map for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { t_field* field = *f_iter; std::string field_name = field->get_name(); - indent(out) << "tmpMap.put(_Fields." << constant_name(field_name) << ", new FieldMetaData(\"" << field_name << "\", "; + indent(out) << "tmpMap.put(_Fields." << constant_name(field_name) << ", new org.apache.thrift.meta_data.FieldMetaData(\"" << field_name << "\", "; // Set field requirement type (required, optional, etc.) if (field->get_req() == t_field::T_REQUIRED) { - out << "TFieldRequirementType.REQUIRED, "; + out << "org.apache.thrift.TFieldRequirementType.REQUIRED, "; } else if (field->get_req() == t_field::T_OPTIONAL) { - out << "TFieldRequirementType.OPTIONAL, "; + out << "org.apache.thrift.TFieldRequirementType.OPTIONAL, "; } else { - out << "TFieldRequirementType.DEFAULT, "; + out << "org.apache.thrift.TFieldRequirementType.DEFAULT, "; } // Create value meta data @@ -2088,38 +2070,38 @@ void t_java_generator::generate_java_meta_data_map(ofstream& out, indent(out) << "metaDataMap = Collections.unmodifiableMap(tmpMap);" << endl; - indent(out) << "FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ".class, metaDataMap);" << endl; + indent(out) << "org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(" << type_name(tstruct) << ".class, metaDataMap);" << endl; indent_down(); indent(out) << "}" << endl << endl; } /** * Returns a string with the java representation of the given thrift type - * (e.g. for the type struct it returns "TType.STRUCT") + * (e.g. for the type struct it returns "org.apache.thrift.protocol.TType.STRUCT") */ std::string t_java_generator::get_java_type_string(t_type* type) { if (type->is_list()){ - return "TType.LIST"; + return "org.apache.thrift.protocol.TType.LIST"; } else if (type->is_map()) { - return "TType.MAP"; + return "org.apache.thrift.protocol.TType.MAP"; } else if (type->is_set()) { - return "TType.SET"; + return "org.apache.thrift.protocol.TType.SET"; } else if (type->is_struct() || type->is_xception()) { - return "TType.STRUCT"; + return "org.apache.thrift.protocol.TType.STRUCT"; } else if (type->is_enum()) { - return "TType.ENUM"; + return "org.apache.thrift.protocol.TType.ENUM"; } else if (type->is_typedef()) { return get_java_type_string(((t_typedef*)type)->get_type()); } else if (type->is_base_type()) { switch (((t_base_type*)type)->get_base()) { - case t_base_type::TYPE_VOID : return "TType.VOID"; break; - case t_base_type::TYPE_STRING : return "TType.STRING"; break; - case t_base_type::TYPE_BOOL : return "TType.BOOL"; break; - case t_base_type::TYPE_BYTE : return "TType.BYTE"; break; - case t_base_type::TYPE_I16 : return "TType.I16"; break; - case t_base_type::TYPE_I32 : return "TType.I32"; break; - case t_base_type::TYPE_I64 : return "TType.I64"; break; - case t_base_type::TYPE_DOUBLE : return "TType.DOUBLE"; break; + case t_base_type::TYPE_VOID : return "org.apache.thrift.protocol.TType.VOID"; break; + case t_base_type::TYPE_STRING : return "org.apache.thrift.protocol.TType.STRING"; break; + case t_base_type::TYPE_BOOL : return "org.apache.thrift.protocol.TType.BOOL"; break; + case t_base_type::TYPE_BYTE : return "org.apache.thrift.protocol.TType.BYTE"; break; + case t_base_type::TYPE_I16 : return "org.apache.thrift.protocol.TType.I16"; break; + case t_base_type::TYPE_I32 : return "org.apache.thrift.protocol.TType.I32"; break; + case t_base_type::TYPE_I64 : return "org.apache.thrift.protocol.TType.I64"; break; + case t_base_type::TYPE_DOUBLE : return "org.apache.thrift.protocol.TType.DOUBLE"; break; default : throw std::runtime_error("Unknown thrift type \"" + type->get_name() + "\" passed to t_java_generator::get_java_type_string!"); break; // This should never happen! } } else { @@ -2132,18 +2114,18 @@ void t_java_generator::generate_field_value_meta_data(std::ofstream& out, t_type indent_up(); indent_up(); if (type->is_struct()){ - indent(out) << "new StructMetaData(TType.STRUCT, " << type_name(type) << ".class"; + indent(out) << "new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, " << type_name(type) << ".class"; } else if (type->is_container()){ if (type->is_list()){ - indent(out) << "new ListMetaData(TType.LIST, "; + indent(out) << "new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, "; t_type* elem_type = ((t_list*)type)->get_elem_type(); generate_field_value_meta_data(out, elem_type); } else if (type->is_set()){ - indent(out) << "new SetMetaData(TType.SET, "; + indent(out) << "new org.apache.thrift.meta_data.SetMetaData(org.apache.thrift.protocol.TType.SET, "; t_type* elem_type = ((t_list*)type)->get_elem_type(); generate_field_value_meta_data(out, elem_type); } else{ // map - indent(out) << "new MapMetaData(TType.MAP, "; + indent(out) << "new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP, "; t_type* key_type = ((t_map*)type)->get_key_type(); t_type* val_type = ((t_map*)type)->get_val_type(); generate_field_value_meta_data(out, key_type); @@ -2151,9 +2133,9 @@ void t_java_generator::generate_field_value_meta_data(std::ofstream& out, t_type generate_field_value_meta_data(out, val_type); } } else if (type->is_enum()) { - indent(out) << "new EnumMetaData(TType.ENUM, " << type_name(type) << ".class"; + indent(out) << "new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, " << type_name(type) << ".class"; } else { - indent(out) << "new FieldValueMetaData(" << get_java_type_string(type); + indent(out) << "new org.apache.thrift.meta_data.FieldValueMetaData(" << get_java_type_string(type); if (type->is_typedef()) { indent(out) << ", \"" << ((t_typedef*)type)->get_symbolic() << "\""; } else if (((t_base_type*)type)->is_binary()) { @@ -2182,8 +2164,7 @@ void t_java_generator::generate_service(t_service* tservice) { f_service_ << autogen_comment() << java_package() << - java_type_imports() << - java_thrift_imports(); + java_type_imports(); f_service_ << "public class " << service_name_ << " {" << endl << @@ -2244,7 +2225,7 @@ void t_java_generator::generate_service_async_interface(t_service* tservice) { vector functions = tservice->get_functions(); vector::iterator f_iter; for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { - indent(f_service_) << "public " << function_signature_async(*f_iter, true) << " throws TException;" << endl << endl; + indent(f_service_) << "public " << function_signature_async(*f_iter, true) << " throws org.apache.thrift.TException;" << endl << endl; } indent_down(); f_service_ << indent() << "}" << endl << endl; @@ -2279,18 +2260,18 @@ void t_java_generator::generate_service_client(t_service* tservice) { } indent(f_service_) << - "public static class Client" << extends_client << " implements TServiceClient, Iface {" << endl; + "public static class Client" << extends_client << " implements org.apache.thrift.TServiceClient, Iface {" << endl; indent_up(); - indent(f_service_) << "public static class Factory implements TServiceClientFactory {" << endl; + indent(f_service_) << "public static class Factory implements org.apache.thrift.TServiceClientFactory {" << endl; indent_up(); indent(f_service_) << "public Factory() {}" << endl; - indent(f_service_) << "public Client getClient(TProtocol prot) {" << endl; + indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol prot) {" << endl; indent_up(); indent(f_service_) << "return new Client(prot);" << endl; indent_down(); indent(f_service_) << "}" << endl; - indent(f_service_) << "public Client getClient(TProtocol iprot, TProtocol oprot) {" << endl; + indent(f_service_) << "public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) {" << endl; indent_up(); indent(f_service_) << "return new Client(iprot, oprot);" << endl; indent_down(); @@ -2299,7 +2280,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { indent(f_service_) << "}" << endl << endl; indent(f_service_) << - "public Client(TProtocol prot)" << endl; + "public Client(org.apache.thrift.protocol.TProtocol prot)" << endl; scope_up(f_service_); indent(f_service_) << "this(prot, prot);" << endl; @@ -2307,7 +2288,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { f_service_ << endl; indent(f_service_) << - "public Client(TProtocol iprot, TProtocol oprot)" << endl; + "public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot)" << endl; scope_up(f_service_); if (extends.empty()) { f_service_ << @@ -2322,14 +2303,14 @@ void t_java_generator::generate_service_client(t_service* tservice) { if (extends.empty()) { f_service_ << - indent() << "protected TProtocol iprot_;" << endl << - indent() << "protected TProtocol oprot_;" << endl << + indent() << "protected org.apache.thrift.protocol.TProtocol iprot_;" << endl << + indent() << "protected org.apache.thrift.protocol.TProtocol oprot_;" << endl << endl << indent() << "protected int seqid_;" << endl << endl; indent(f_service_) << - "public TProtocol getInputProtocol()" << endl; + "public org.apache.thrift.protocol.TProtocol getInputProtocol()" << endl; scope_up(f_service_); indent(f_service_) << "return this.iprot_;" << endl; @@ -2337,7 +2318,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { f_service_ << endl; indent(f_service_) << - "public TProtocol getOutputProtocol()" << endl; + "public org.apache.thrift.protocol.TProtocol getOutputProtocol()" << endl; scope_up(f_service_); indent(f_service_) << "return this.oprot_;" << endl; @@ -2400,7 +2381,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { // Serialize the request f_service_ << - indent() << "oprot_.writeMessageBegin(new TMessage(\"" << funname << "\", TMessageType.CALL, ++seqid_));" << endl << + indent() << "oprot_.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << funname << "\", org.apache.thrift.protocol.TMessageType.CALL, ++seqid_));" << endl << indent() << argsname << " args = new " << argsname << "();" << endl; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { @@ -2430,14 +2411,14 @@ void t_java_generator::generate_service_client(t_service* tservice) { scope_up(f_service_); f_service_ << - indent() << "TMessage msg = iprot_.readMessageBegin();" << endl << - indent() << "if (msg.type == TMessageType.EXCEPTION) {" << endl << - indent() << " TApplicationException x = TApplicationException.read(iprot_);" << endl << + indent() << "org.apache.thrift.protocol.TMessage msg = iprot_.readMessageBegin();" << endl << + indent() << "if (msg.type == org.apache.thrift.protocol.TMessageType.EXCEPTION) {" << endl << + indent() << " org.apache.thrift.TApplicationException x = org.apache.thrift.TApplicationException.read(iprot_);" << endl << indent() << " iprot_.readMessageEnd();" << endl << indent() << " throw x;" << endl << indent() << "}" << endl << indent() << "if (msg.seqid != seqid_) {" << endl << - indent() << " throw new TApplicationException(TApplicationException.BAD_SEQUENCE_ID, \"" << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl << + indent() << " throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.BAD_SEQUENCE_ID, \"" << (*f_iter)->get_name() << " failed: out of sequence response\");" << endl << indent() << "}" << endl << indent() << resultname << " result = new " << resultname << "();" << endl << indent() << "result.read(iprot_);" << endl << @@ -2467,7 +2448,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { "return;" << endl; } else { f_service_ << - indent() << "throw new TApplicationException(TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl; + indent() << "throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, \"" << (*f_iter)->get_name() << " failed: unknown result\");" << endl; } // Close function @@ -2482,7 +2463,7 @@ void t_java_generator::generate_service_client(t_service* tservice) { } void t_java_generator::generate_service_async_client(t_service* tservice) { - string extends = "TAsyncClient"; + string extends = "org.apache.thrift.async.TAsyncClient"; string extends_client = ""; if (tservice->get_extends() != NULL) { extends = type_name(tservice->get_extends()) + ".AsyncClient"; @@ -2493,19 +2474,19 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { indent_up(); // Factory method - indent(f_service_) << "public static class Factory implements TAsyncClientFactory {" << endl; - indent(f_service_) << " private TAsyncClientManager clientManager;" << endl; - indent(f_service_) << " private TProtocolFactory protocolFactory;" << endl; - indent(f_service_) << " public Factory(TAsyncClientManager clientManager, TProtocolFactory protocolFactory) {" << endl; + indent(f_service_) << "public static class Factory implements org.apache.thrift.async.TAsyncClientFactory {" << endl; + indent(f_service_) << " private org.apache.thrift.async.TAsyncClientManager clientManager;" << endl; + indent(f_service_) << " private org.apache.thrift.protocol.TProtocolFactory protocolFactory;" << endl; + indent(f_service_) << " public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) {" << endl; indent(f_service_) << " this.clientManager = clientManager;" << endl; indent(f_service_) << " this.protocolFactory = protocolFactory;" << endl; indent(f_service_) << " }" << endl; - indent(f_service_) << " public AsyncClient getAsyncClient(TNonblockingTransport transport) {" << endl; + indent(f_service_) << " public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) {" << endl; indent(f_service_) << " return new AsyncClient(protocolFactory, clientManager, transport);" << endl; indent(f_service_) << " }" << endl; indent(f_service_) << "}" << endl << endl; - indent(f_service_) << "public AsyncClient(TProtocolFactory protocolFactory, TAsyncClientManager clientManager, TNonblockingTransport transport) {" << endl; + indent(f_service_) << "public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) {" << endl; indent(f_service_) << " super(protocolFactory, clientManager, transport);" << endl; indent(f_service_) << "}" << endl << endl; @@ -2524,7 +2505,7 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { string result_name = (*f_iter)->get_name() + "_result"; // Main method body - indent(f_service_) << "public " << function_signature_async(*f_iter, false) << " throws TException {" << endl; + indent(f_service_) << "public " << function_signature_async(*f_iter, false) << " throws org.apache.thrift.TException {" << endl; indent(f_service_) << " checkReady();" << endl; indent(f_service_) << " " << funclassname << " method_call = new " + funclassname + "(" << async_argument_list(*f_iter, arg_struct, ret_type) << ", this, protocolFactory, transport);" << endl; indent(f_service_) << " this.currentMethod = method_call;" << endl; @@ -2534,7 +2515,7 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { f_service_ << endl; // TAsyncMethod object for this function call - indent(f_service_) << "public static class " + funclassname + " extends TAsyncMethodCall {" << endl; + indent(f_service_) << "public static class " + funclassname + " extends org.apache.thrift.async.TAsyncMethodCall {" << endl; indent_up(); // Member variables @@ -2546,7 +2527,7 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { // indent(f_service_) << "private int seqid;" << endl << endl; // Constructor - indent(f_service_) << "public " + funclassname + "(" + async_argument_list(*f_iter, arg_struct, ret_type, true) << ", TAsyncClient client, TProtocolFactory protocolFactory, TNonblockingTransport transport) throws TException {" << endl; + indent(f_service_) << "public " + funclassname + "(" + async_argument_list(*f_iter, arg_struct, ret_type, true) << ", org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException {" << endl; indent(f_service_) << " super(client, protocolFactory, transport, resultHandler, " << ((*f_iter)->is_oneway() ? "true" : "false") << ");" << endl; // Assign member variables @@ -2556,13 +2537,13 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { indent(f_service_) << "}" << endl << endl; - indent(f_service_) << "public void write_args(TProtocol prot) throws TException {" << endl; + indent(f_service_) << "public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException {" << endl; indent_up(); // Serialize request // NOTE we are leaving seqid as 0, for now (see above) f_service_ << - indent() << "prot.writeMessageBegin(new TMessage(\"" << funname << "\", TMessageType.CALL, 0));" << endl << + indent() << "prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << funname << "\", org.apache.thrift.protocol.TMessageType.CALL, 0));" << endl << indent() << args_name << " args = new " << args_name << "();" << endl; for (fld_iter = fields.begin(); fld_iter != fields.end(); ++fld_iter) { @@ -2582,15 +2563,15 @@ void t_java_generator::generate_service_async_client(t_service* tservice) { for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { f_service_ << type_name((*x_iter)->get_type(), false, false) + ", "; } - f_service_ << "TException {" << endl; + f_service_ << "org.apache.thrift.TException {" << endl; indent_up(); f_service_ << - indent() << "if (getState() != State.RESPONSE_READ) {" << endl << + indent() << "if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) {" << endl << indent() << " throw new IllegalStateException(\"Method call not finished!\");" << endl << indent() << "}" << endl << - indent() << "TMemoryInputTransport memoryTransport = new TMemoryInputTransport(getFrameBuffer().array());" << endl << - indent() << "TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);" << endl; + indent() << "org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array());" << endl << + indent() << "org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport);" << endl; if (!(*f_iter)->is_oneway()) { indent(f_service_); if (!ret_type->is_void()) { @@ -2633,7 +2614,7 @@ void t_java_generator::generate_service_server(t_service* tservice) { // Generate the header portion indent(f_service_) << - "public static class Processor" << extends_processor << " implements TProcessor {" << endl; + "public static class Processor" << extends_processor << " implements org.apache.thrift.TProcessor {" << endl; indent_up(); indent(f_service_) << "private static final Logger LOGGER = LoggerFactory.getLogger(Processor.class.getName());" << endl; @@ -2659,7 +2640,7 @@ void t_java_generator::generate_service_server(t_service* tservice) { if (extends.empty()) { f_service_ << indent() << "protected static interface ProcessFunction {" << endl << - indent() << " public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" << endl << + indent() << " public void process(int seqid, org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException;" << endl << indent() << "}" << endl << endl; } @@ -2676,21 +2657,21 @@ void t_java_generator::generate_service_server(t_service* tservice) { // Generate the server implementation indent(f_service_) << - "public boolean process(TProtocol iprot, TProtocol oprot) throws TException" << endl; + "public boolean process(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException" << endl; scope_up(f_service_); f_service_ << - indent() << "TMessage msg = iprot.readMessageBegin();" << endl; + indent() << "org.apache.thrift.protocol.TMessage msg = iprot.readMessageBegin();" << endl; // TODO(mcslee): validate message, was the seqid etc. legit? f_service_ << indent() << "ProcessFunction fn = processMap_.get(msg.name);" << endl << indent() << "if (fn == null) {" << endl << - indent() << " TProtocolUtil.skip(iprot, TType.STRUCT);" << endl << + indent() << " org.apache.thrift.protocol.TProtocolUtil.skip(iprot, org.apache.thrift.protocol.TType.STRUCT);" << endl << indent() << " iprot.readMessageEnd();" << endl << - indent() << " TApplicationException x = new TApplicationException(TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl << - indent() << " oprot.writeMessageBegin(new TMessage(msg.name, TMessageType.EXCEPTION, msg.seqid));" << endl << + indent() << " org.apache.thrift.TApplicationException x = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.UNKNOWN_METHOD, \"Invalid method name: '\"+msg.name+\"'\");" << endl << + indent() << " oprot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(msg.name, org.apache.thrift.protocol.TMessageType.EXCEPTION, msg.seqid));" << endl << indent() << " x.write(oprot);" << endl << indent() << " oprot.writeMessageEnd();" << endl << indent() << " oprot.getTransport().flush();" << endl << @@ -2756,7 +2737,7 @@ void t_java_generator::generate_process_function(t_service* tservice, // Open function indent(f_service_) << - "public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException" << endl; + "public void process(int seqid, org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException" << endl; scope_up(f_service_); string argsname = tfunction->get_name() + "_args"; @@ -2770,12 +2751,12 @@ void t_java_generator::generate_process_function(t_service* tservice, indent() << "args.read(iprot);" << endl; indent_down(); f_service_ << - indent() << "} catch (TProtocolException e) {" << endl; + indent() << "} catch (org.apache.thrift.protocol.TProtocolException e) {" << endl; indent_up(); f_service_ << indent() << "iprot.readMessageEnd();" << endl << - indent() << "TApplicationException x = new TApplicationException(TApplicationException.PROTOCOL_ERROR, e.getMessage());" << endl << - indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl << + indent() << "org.apache.thrift.TApplicationException x = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.PROTOCOL_ERROR, e.getMessage());" << endl << + indent() << "oprot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << tfunction->get_name() << "\", org.apache.thrift.protocol.TMessageType.EXCEPTION, seqid));" << endl << indent() << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl << indent() << "oprot.getTransport().flush();" << endl << @@ -2849,8 +2830,8 @@ void t_java_generator::generate_process_function(t_service* tservice, indent_up(); f_service_ << indent() << "LOGGER.error(\"Internal error processing " << tfunction->get_name() << "\", th);" << endl << - indent() << "TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, \"Internal error processing " << tfunction->get_name() << "\");" << endl << - indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.EXCEPTION, seqid));" << endl << + indent() << "org.apache.thrift.TApplicationException x = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, \"Internal error processing " << tfunction->get_name() << "\");" << endl << + indent() << "oprot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << tfunction->get_name() << "\", org.apache.thrift.protocol.TMessageType.EXCEPTION, seqid));" << endl << indent() << "x.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl << indent() << "oprot.getTransport().flush();" << endl << @@ -2874,7 +2855,7 @@ void t_java_generator::generate_process_function(t_service* tservice, } f_service_ << - indent() << "oprot.writeMessageBegin(new TMessage(\"" << tfunction->get_name() << "\", TMessageType.REPLY, seqid));" << endl << + indent() << "oprot.writeMessageBegin(new org.apache.thrift.protocol.TMessage(\"" << tfunction->get_name() << "\", org.apache.thrift.protocol.TMessageType.REPLY, seqid));" << endl << indent() << "result.write(oprot);" << endl << indent() << "oprot.writeMessageEnd();" << endl << indent() << "oprot.getTransport().flush();" << endl; @@ -2991,11 +2972,11 @@ void t_java_generator::generate_deserialize_container(ofstream& out, // Declare variables, read header if (ttype->is_map()) { - indent(out) << "TMap " << obj << " = iprot.readMapBegin();" << endl; + indent(out) << "org.apache.thrift.protocol.TMap " << obj << " = iprot.readMapBegin();" << endl; } else if (ttype->is_set()) { - indent(out) << "TSet " << obj << " = iprot.readSetBegin();" << endl; + indent(out) << "org.apache.thrift.protocol.TSet " << obj << " = iprot.readSetBegin();" << endl; } else if (ttype->is_list()) { - indent(out) << "TList " << obj << " = iprot.readListBegin();" << endl; + indent(out) << "org.apache.thrift.protocol.TList " << obj << " = iprot.readListBegin();" << endl; } indent(out) @@ -3204,18 +3185,18 @@ void t_java_generator::generate_serialize_container(ofstream& out, if (ttype->is_map()) { indent(out) << - "oprot.writeMapBegin(new TMap(" << + "oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(" << type_to_enum(((t_map*)ttype)->get_key_type()) << ", " << type_to_enum(((t_map*)ttype)->get_val_type()) << ", " << prefix << ".size()));" << endl; } else if (ttype->is_set()) { indent(out) << - "oprot.writeSetBegin(new TSet(" << + "oprot.writeSetBegin(new org.apache.thrift.protocol.TSet(" << type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " << prefix << ".size()));" << endl; } else if (ttype->is_list()) { indent(out) << - "oprot.writeListBegin(new TList(" << + "oprot.writeListBegin(new org.apache.thrift.protocol.TList(" << type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " << prefix << ".size()));" << endl; } @@ -3454,7 +3435,7 @@ string t_java_generator::function_signature(t_function* tfunction, for (x_iter = xceptions.begin(); x_iter != xceptions.end(); ++x_iter) { result += type_name((*x_iter)->get_type(), false, false) + ", "; } - result += "TException"; + result += "org.apache.thrift.TException"; return result; } @@ -3490,7 +3471,7 @@ string t_java_generator::async_function_call_arglist(t_function* tfunc, bool use ret_type += tfunc->get_name() + "_call"; if (include_types) { - arglist += "AsyncMethodCallback<" + ret_type + "> "; + arglist += "org.apache.thrift.async.AsyncMethodCallback<" + ret_type + "> "; } arglist += "resultHandler"; @@ -3541,7 +3522,7 @@ string t_java_generator::async_argument_list(t_function* tfunct, t_struct* tstru result += ", "; } if (include_types) { - result += "AsyncMethodCallback<" + tfunct->get_name() + "_call" + "> "; + result += "org.apache.thrift.async.AsyncMethodCallback<" + tfunct->get_name() + "_call" + "> "; } result += "resultHandler"; return result; @@ -3559,30 +3540,30 @@ string t_java_generator::type_to_enum(t_type* type) { case t_base_type::TYPE_VOID: throw "NO T_VOID CONSTRUCT"; case t_base_type::TYPE_STRING: - return "TType.STRING"; + return "org.apache.thrift.protocol.TType.STRING"; case t_base_type::TYPE_BOOL: - return "TType.BOOL"; + return "org.apache.thrift.protocol.TType.BOOL"; case t_base_type::TYPE_BYTE: - return "TType.BYTE"; + return "org.apache.thrift.protocol.TType.BYTE"; case t_base_type::TYPE_I16: - return "TType.I16"; + return "org.apache.thrift.protocol.TType.I16"; case t_base_type::TYPE_I32: - return "TType.I32"; + return "org.apache.thrift.protocol.TType.I32"; case t_base_type::TYPE_I64: - return "TType.I64"; + return "org.apache.thrift.protocol.TType.I64"; case t_base_type::TYPE_DOUBLE: - return "TType.DOUBLE"; + return "org.apache.thrift.protocol.TType.DOUBLE"; } } else if (type->is_enum()) { - return "TType.I32"; + return "org.apache.thrift.protocol.TType.I32"; } else if (type->is_struct() || type->is_xception()) { - return "TType.STRUCT"; + return "org.apache.thrift.protocol.TType.STRUCT"; } else if (type->is_map()) { - return "TType.MAP"; + return "org.apache.thrift.protocol.TType.MAP"; } else if (type->is_set()) { - return "TType.SET"; + return "org.apache.thrift.protocol.TType.SET"; } else if (type->is_list()) { - return "TType.LIST"; + return "org.apache.thrift.protocol.TType.LIST"; } throw "INVALID TYPE IN type_to_enum: " + type->get_name(); @@ -3772,7 +3753,7 @@ void t_java_generator::generate_deep_copy_non_container(ofstream& out, std::stri (void) dest_name; if (type->is_base_type() || type->is_enum() || type->is_typedef()) { if (((t_base_type*)type)->is_binary()) { - out << "TBaseHelper.copyBinary(" << source_name << ");" << endl; + out << "org.apache.thrift.TBaseHelper.copyBinary(" << source_name << ");" << endl; } else { // everything else can be copied directly out << source_name; @@ -3811,7 +3792,7 @@ std::string t_java_generator::get_enum_class_name(t_type* type) { void t_java_generator::generate_struct_desc(ofstream& out, t_struct* tstruct) { indent(out) << - "private static final TStruct STRUCT_DESC = new TStruct(\"" << tstruct->get_name() << "\");" << endl; + "private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct(\"" << tstruct->get_name() << "\");" << endl; } void t_java_generator::generate_field_descs(ofstream& out, t_struct* tstruct) { @@ -3820,8 +3801,8 @@ void t_java_generator::generate_field_descs(ofstream& out, t_struct* tstruct) { for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { indent(out) << - "private static final TField " << constant_name((*m_iter)->get_name()) << - "_FIELD_DESC = new TField(\"" << (*m_iter)->get_name() << "\", " << + "private static final org.apache.thrift.protocol.TField " << constant_name((*m_iter)->get_name()) << + "_FIELD_DESC = new org.apache.thrift.protocol.TField(\"" << (*m_iter)->get_name() << "\", " << type_to_enum((*m_iter)->get_type()) << ", " << "(short)" << (*m_iter)->get_key() << ");" << endl; } @@ -3829,7 +3810,7 @@ void t_java_generator::generate_field_descs(ofstream& out, t_struct* tstruct) { void t_java_generator::generate_field_name_constants(ofstream& out, t_struct* tstruct) { indent(out) << "/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */" << endl; - indent(out) << "public enum _Fields implements TFieldIdEnum {" << endl; + indent(out) << "public enum _Fields implements org.apache.thrift.TFieldIdEnum {" << endl; indent_up(); bool first = true; -- 2.17.1