Use AbstractMap instead of HashMap

Summary: So ConcurrentHashMap can be used safely


git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664859 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 c5ca1ec..f61db38 100644
--- a/compiler/cpp/src/generate/t_java_generator.cc
+++ b/compiler/cpp/src/generate/t_java_generator.cc
@@ -37,6 +37,7 @@
   return
     string() +
     "import java.util.ArrayList;\n" +
+    "import java.util.AbstractMap;\n" +
     "import java.util.HashMap;\n" +
     "import java.util.HashSet;\n" +
     "import com.facebook.thrift.*;\n\n";
@@ -701,7 +702,7 @@
   
   if (extends.empty()) {
     f_service_ <<
-      indent() << "private static interface ProcessFunction {" << endl <<
+      indent() << "protected static interface ProcessFunction {" << endl <<
       indent() << "  public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException;" << endl <<
       indent() << "}" << endl <<
       endl;
@@ -1313,7 +1314,7 @@
  * @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) {
+string t_java_generator::type_name(t_type* ttype, bool in_container, bool in_init) {
   // In Java typedefs are just resolved to their real type
   while (ttype->is_typedef()) {
     ttype = ((t_typedef*)ttype)->get_type();
@@ -1325,7 +1326,13 @@
     return (in_container ? "Integer" : "int");
   } else if (ttype->is_map()) {
     t_map* tmap = (t_map*) ttype;
-    return "HashMap<" +
+    string prefix;
+    if (in_init) {
+      prefix = "HashMap";
+    } else {
+      prefix = "AbstractMap";
+    }
+    return prefix + "<" +
       type_name(tmap->get_key_type(), true) + "," +
       type_name(tmap->get_val_type(), true) + ">";
   } else if (ttype->is_set()) {
@@ -1417,7 +1424,7 @@
     } else if (ttype->is_enum()) {
       result += " = 0";
     } else if (ttype->is_container()) {
-      result += " = new " + type_name(ttype) + "()";
+      result += " = new " + type_name(ttype, false, true) + "()";
     } else {
       result += " = null";
     }
diff --git a/compiler/cpp/src/generate/t_java_generator.h b/compiler/cpp/src/generate/t_java_generator.h
index 2b60e73..b319ab4 100644
--- a/compiler/cpp/src/generate/t_java_generator.h
+++ b/compiler/cpp/src/generate/t_java_generator.h
@@ -117,7 +117,7 @@
   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);
+  std::string type_name(t_type* ttype, bool in_container=false, bool in_init=false);
   std::string base_type_name(t_base_type::t_base tbase, bool in_container=false);
   std::string declare_field(t_field* tfield, bool init=false);
   std::string function_signature(t_function* tfunction, std::string prefix="");