title: Store class generic in field in Java
body: <p>Is there any way to store the generic parameter type passed in at construction to a parameter.  My goal:</p>
  
  <pre><code>class generic&lt;T&gt; {
      Class&lt;T&gt; type;
      public generic() {
          super();
          this.type = //Something that gets class from T
      }
  }
  </code></pre>
  
  <p>What I'm currently doing is this:</p>
  
  <pre><code>class generic&lt;T&gt; {
      Class&lt;T&gt; type;
      public generic(Class&lt;T&gt; type) {
          super();
          this.type = type;
      }
  }
  </code></pre>
  
  <p>It seems silly to have to specify the class twice, but I'm not sure of how else to do it.  I think this might be possible with reflection, but I haven't investigated that yet.  Is there a more straightforward way?  If not (as an aside) why the information loss?</p>