title: How to convert generic parameter to a class
body: <pre><code>public abstract class BaseDaoImpl&lt;E extends AbstractEntity&gt; implements BaseDao&lt;E&gt; {
  
      .....
  
      public BaseDaoImpl() throws DataAccessException {
          logger = LoggerFactory.getLogger(E);  &lt;&lt;-- error here.
      }
  </code></pre>
  
  <p>In the above code I get a error in the call to <code>getLogger(E)</code>.</p>
  
  <blockquote>
    <p>E cannot be resolved to a variable</p>
  </blockquote>
  
  <p>This makes sense, but <code>getLogger(E.class)</code> (or variants thereof) does not work either.</p>
  
  <p>I don't want to pass the literal class in the constructor, so a solution like changing the the constructor header to:<br>
  <code>public BaseDaoImpl(Class&lt;E&gt; clazz) ...</code> is not an option.</p>
  
  <p><strong>How do I get the class type from <code>E</code>?</strong></p>
  
  <p>Note that the answers to: <a href="https://stackoverflow.com/questions/8436055/how-to-get-class-of-generic-type-when-there-is-no-parameter-of-it">How to get class of generic type when there is no parameter of it?</a><br>
  do not help.</p>