title: Java Generics Type Erasure byte code
body: <p>As per the java documentation on <a href="http://docs.oracle.com/javase/tutorial/java/generics/genTypes.html" rel="noreferrer">Erasure of Generic Types</a>, </p>
  
  <p>Consider the following generic class that represents a node in a singly linked list:</p>
  
  <pre><code>public class Node&lt;T&gt; {
  
      private T data;
      private Node&lt;T&gt; next;
  
      public Node(T data, Node&lt;T&gt; next) }
          this.data = data;
          this.next = next;
      }
  
      public T getData() { return data; }
      // ...
  }
  </code></pre>
  
  <p>Because the type parameter <strong>T</strong> is unbounded, the Java compiler replaces it with <strong>Object</strong>:</p>
  
  <pre><code>public class Node {
  
      private Object data;
      private Node next;
  
      public Node(Object data, Node next) {
          this.data = data;
          this.next = next;
      }
  
      public Object getData() { return data; }
      // ...
  }
  </code></pre>
  
  <p>But after compilation with Java 1.7.0_11, when I opened it with any decompiler I can see the same code as like source code.</p>
  
  <pre><code>public class Node&lt;T&gt;
  {
    private T data;
    private Node&lt;T&gt; next;
  
    public Node(T paramT, Node&lt;T&gt; paramNode)
    {
      this.data = paramT;
      this.next = paramNode;
    }
  
    public T getData()
    {
      return this.data;
    }
  }
  </code></pre>
  
  <p>If Type-Erasure applied at compile then the byte code must not contain Generic information as shown above. Kindly clarify me.</p>
  
  <p><strong>NOTE:</strong> I am using <a href="https://code.google.com/p/innlab/downloads/detail?name=jd-gui-0.3.3.windows.zip&amp;" rel="noreferrer">JD-GUI</a> as a decompiler to analyze the byte code</p>