title: How to determine the class of a generic type?
body: <p>I'm creating a generic class and in one of the methods I need to know the Class of the generic type currently in use. The reason is that one of the method's I call expects this as an argument.</p>
  
  <p>Example:</p>
  
  <pre><code>public class MyGenericClass&lt;T&gt; {
    public void doSomething() {
      // Snip...
      // Call to a 3rd party lib
      T bean = (T)someObject.create(T.class);
      // Snip...
    }
  }
  </code></pre>
  
  <p>Clearly the example above doesn't work  and results in the following error: Illegal class literal for the type parameter T.</p>
  
  <p>My question is: does someone know a good alternative or workaround for this?</p>