title: No ClassCastException when casting to generic type different to actual class
body: <p>I have some code which looks something like this (part of a negative test of the method <code>get</code>):</p>
  
  <pre><code>import java.util.*;
  public class Test {
      Map&lt;String, Object&gt; map = new HashMap&lt;&gt;();
      public static void main (String ... args) {
          Test test = new Test();
          test.put("test", "value"); // Store a String
          System.out.println("Test: " + test.get("test", Double.class)); // Retrieve it as a Double
      }
  
      public &lt;T&gt; T get(String key, Class&lt;T&gt; clazz) {
          return (T) map.get(key);
      }
  
      public void put(String key, Object value) {
          map.put(key, value);
      }
  }
  </code></pre>
  
  <p>I was expecting it to throw a <code>ClassCastException</code> but it runs through successfully printing:</p>
  
  <pre><code>Test: value
  </code></pre>
  
  <p>Why doesn't it throw?</p>