title: Java - Error deserializing HashTable containing primitive type
body: <p>I have serialized a <code>HashTable&lt;String,Object&gt;</code> object using an <code>ObjectOutputStream</code>. When serializing the object, I get no exception, but upon deserialization, the following exception occurs:</p>
  
  <pre><code>Exception in thread "main" java.io.InvalidClassException: java.lang.Long; local class
  incompatible: stream classdesc serialVersionUID = 4290774032661291999, local class
  serialVersionUID = 4290774380558885855
  </code></pre>
  
  <p>I no longer get the error when I remove all of the keys in the <code>HashTable</code> that have a value that is not a <code>String</code> (all of the key / value pairs I removed had a primitive type as their value).</p>
  
  <p>What could be causing this error?</p>
  
  <p><strong>UPDATE - Here's the code</strong></p>
  
  <pre><code>public static String serialize(Quiz quiz) throws IOException{
      HashMap&lt;String,Object&gt; quizData = new HashMap&lt;String,Object&gt;();
      quizData.put("version", 0); //int
      quizData.put("name", quiz.getName()); //String
      quizData.put("desc", quiz.getDesc()); //String
      quizData.put("timelimitType", quiz.getTimelimitType()); //String
      quizData.put("timelimit", quiz.getTimelimit()); //long
      ArrayList&lt;String&gt; serializedQuestionsData = new ArrayList&lt;String&gt;();
      for (Question question : quiz.getQuestions())
          serializedQuestionsData.add(Question.serialize(question));
      quizData.put("questions", serializedQuestionsData.toArray(new String[0])); //String[]
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ObjectOutputStream oos;
      try { oos = new ObjectOutputStream(baos); } catch (IOException error){ throw error; }
      try { oos.writeObject(quizData); } catch (IOException error){ throw error; }
      return baos.toString();
  }
  @SuppressWarnings("unchecked")
  public static Quiz deserialize(String serializedQuizData) throws IOException, ClassNotFoundException{
      ByteArrayInputStream bais = new ByteArrayInputStream(serializedQuizData.getBytes());
      ObjectInputStream ois;
      try { ois = new ObjectInputStream(bais); } catch (IOException error){ throw error; }
      HashMap&lt;String,Object&gt; quizData;
      // Exception occurs on the following line!!
      try { quizData = (HashMap&lt;String,Object&gt;) ois.readObject(); } catch (ClassNotFoundException error){ throw error; }
      Quiz quiz;
      if ((int) quizData.get("version") == 0){
          quiz = new Quiz((String) quizData.get("name"),
                  (String) quizData.get("desc"),
                  (String) quizData.get("timelimitType"),
                  (long) quizData.get("timelimit"));
          for (String serializedQuestionData : (String[]) quizData.get("questions"))
              quiz.addQuestion(Question.deserialize(serializedQuestionData));
      } else {
          throw new UnsupportedOperationException("Unsupported version: \"" + quizData.get("version") + "\"");
      }
      return quiz;
  }
  </code></pre>