Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange exception during deserialization
    primarykey
    data
    text
    <p>I need to deserialize object but when I'm reading object using readObject i get such exception:</p> <pre><code>Exception raised: java.lang.Enum; Incompatible class (SUID): java.lang.Enum: static final long serialVersionUID =0L; but expected java.lang.Enum: static final long serialVersionUID =0L; </code></pre> <p>Here's the code:</p> <pre><code>public static void restore3x(PersistentHistory h, DictManager dictManager) throws Exception{ SharedPreferences prefs = tryToGuess(h.mContext); if (prefs == null) return; Log.e("shdd","Found history!"); String history = prefs.getString("History", null); ObjectInputStream objIn = null; try { //prepare objIn = new ObjectInputStream(new ByteArrayInputStream(Base64.decode(history))) { @Override protected ObjectStreamClass readClassDescriptor() throws IOException, ClassNotFoundException { ObjectStreamClass osc = super.readClassDescriptor(); if (osc.getName().contains("slovoed")) { try { Field f; f = osc.getClass().getDeclaredField("svUID"); f.setAccessible(true); Log.e("shdd","Setting serialVersionUID"); f.setLong(osc, serialVersionUID); Log.e("shdd","Set ok"); f = osc.getClass().getDeclaredField("className"); f.setAccessible(true); Log.e("shdd","Setting class name"); f.set(osc, WordItem.class.getName()); Log.e("shdd","Set ok"); } catch (Exception e) { } } return osc; } }; //add to DB Log.e("shdd","Getting items"); Collection&lt;WordItem3x&gt; items = (Collection&lt;WordItem3x&gt;) objIn.readObject(); Log.e("shdd","Got ok"); if (items.isEmpty()) return; Log.e("shdd","List's not empty"); long timeSeconds = System.currentTimeMillis()/1000; for (WordItem3x w : items) { if (w.getWord() == null || w.getWord().length() == 0 || w.getIndexList() == 0) continue; Log.e("shdd","Adding word"); h.add(w.getWord(), w.getIndexList(), timeSeconds--); } } catch (Exception e) { Log.e("shdd","Exception raised: " + e.getMessage()); throw e; } finally { try { if (objIn != null) objIn.close(); } catch (Exception e) {} //prefs.edit().remove("History").commit(); } } </code></pre> <p>I have no idea what's wrong. Maybe someone has seen such exceptions?</p> <p>Here's WordItem3x readObject method:</p> <pre><code>private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException { Log.e("shdd", "Reading object"); in.defaultReadObject(); int val1 = in.readInt(); int val2 = in.readInt(); if (val1 != -1 &amp;&amp; val2 != -1) { direction = new Direction(val1, val2); } else direction = null; val1 = in.readInt(); if (val1 != -1) typeList = eWordListType.values()[val1]; else typeList = null; } </code></pre> <p>But as i can see it's not ever called.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload