title: How do I catch ClassCastException?
body: <p>I'm trying to catch a ClassCastException when deserializing an object from xml.</p>
  
  <p>So,</p>
  
  <pre><code>try {
      restoredItem = (T) decoder.readObject();
  } catch (ClassCastException e){
      //don't need to crash at this point,
     //just let the user know that a wrong file has been passed.
  }
  </code></pre>
  
  <p>And yet this won't as the exception doesn't get caught. What would you suggest?</p>