title: Gson fails to "understand" generic type when deserializing
body: <p>I created this memory class:</p>
  
  <pre><code>public class Memory {
      private final Hashtable&lt;String, String&gt; data;
      private final Gson gson;
  
      public Memory() {
          this.data = new Hashtable&lt;String, String&gt;();
          this.gson = new Gson();
      }
  
      public &lt;T&gt; void set(String key, List&lt;T&gt; value) {
          this.data.put(key, this.gson.toJson(value));
      }
  
      public &lt;T&gt; List&lt;T&gt; get(String key, Class&lt;T&gt; cls) {
          Type type = new TypeToken&lt;List&lt;T&gt;&gt;() {}.getType();
          return this.gson.fromJson(this.data.get(key), type);
      }
  }
  </code></pre>
  
  <p><br/>
  Where I can store lists of generic types in a json and then deserialize them.<br/>
  But when I try to use it, for example like this:</p>
  
  <pre><code>public class User {
      private int id;
      private String username;
  
      public User() { }
  
      public User(int id, String username) {
          this.id = id;
          this.username = username;
      }
  }
  
  Memory memory = new Memory();
  List&lt;User&gt; users = new ArrayList&lt;User&gt;();
  // add users
  memory.set("users", users);
  
  // now get the users back
  List&lt;User&gt; copy = memory.get("users", User.class);
  </code></pre>
  
  <p>Gson returns an ArrayList of StringMap instead of Users.<br/>
  This obviously has something to do with the generics I'm using, but is there a way to bypass it?</p>
  
  <p>Thanks.</p>