title: Java: get generic type
body: <p>I'm writing a Java wrapper for c++ and would like to use a generic class to wrap a c++ template. Therefore I'd like to get the generic type as String so I can further pass it to JNI and instantiate a corresponding c++ object.</p>
  
  <p>EDIT: this is how I implemented it, in case someone is interested:</p>
  
  <pre><code>public class A&lt;T&gt;
  {
      private long ptr; 
  
          public static &lt;E&gt; A&lt;E&gt; create(Class&lt;E&gt; cls)
          {
              return new A&lt;E&gt;(cls); 
          }
  
      private A(Class&lt;T&gt; cls)
      {
          ptr = create( cls.getName() ); 
  
          if(ptr == 0)
          {
              throw new NullPointerException(); 
          }
       }
  
      private native long create(String className); 
  }
  </code></pre>