title: Why java type erasure is needed at runtime at all?
body: <p>Below is an excerpt from <a href="https://docs.oracle.com/javase/7/docs/technotes/guides/language/non-reifiable-varargs.html" rel="nofollow noreferrer">java documentation here</a></p>
  <blockquote>
  <p>Because of type erasure, <code>List&lt;Number&gt;</code> and <code>List&lt;String&gt;</code> both become List. Consequently, the compiler allows the assignment of the object l, which has a raw type of List, to the object ls.</p>
  </blockquote>
  <p>Also from the same documentation</p>
  <blockquote>
  <p>Consider the following example:</p>
  </blockquote>
  <pre><code>List l = new ArrayList&lt;Number&gt;();
  List&lt;String&gt; ls = l;       // unchecked warning
  l.add(0, new Integer(42)); // another unchecked warning
  String s = ls.get(0);      // ClassCastException is thrown
  </code></pre>
  <blockquote>
  <p>During type erasure, the types ArrayList and List become ArrayList and List, respectively.</p>
  </blockquote>
  <p>Why compiler can't show this as an error (instead of warning). Could someone kindly help with an example where warning is needed and will cause an issue (or make certain useful patterns impossible) when warning becomes an error.</p>