title: Extending generics in method parameter
body: <p>I'm trying to extend a library that uses generics in entities and entities manager, so I have the following:</p>
  
  <pre><code>public class MyEntity extends ParentEntity extends BaseEntity
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class MyEntityManager extends ParentEntityManager extends BaseEntityManager&lt;ParentEntity, ParentEntityDao&gt;
  </code></pre>
  
  <p>Now my problem is, I'm using another class of the library to update the entity, and the method I need to call expects:</p>
  
  <pre><code>public &lt;ENT extends BaseEntity&gt; void update (Class&lt;ENT&gt; entityClass, BaseEntityManager&lt;ENT&gt; entityManager)
  </code></pre>
  
  <p>So when I try to call the method with <code>MyEntity</code> and <code>MyEntityManager</code>, it fails because my <code>EntityManager</code> extends from the <code>BaseEntityManager</code> with <code>ParentEntity</code> as parameter, not <code>MyEntity</code>, so they don't match.</p>
  
  <p>I would say that the cleanest way to solve this would be to copy the utility class  that has the update method and extend it in my project, but I would like to make it generic so I can pass it EntityManagers that use any children class of <code>ParentEntity</code>, but I've been trying for a while and I cannot find the solution. </p>
  
  <p>I tried changing the method signature to this:</p>
  
  <pre><code>public &lt;ENT extends BaseEntity&gt; void update (Class&lt;ENT&gt; entityClass, BaseEntityManager&lt;? extends ENT&gt; entityManager)
  </code></pre>
  
  <p>but I'm still getting a compiler exception...</p>
  
  <p>EDIT: Modifying ParentEntityManager, BaseEntityManager or ParentEntity is not possible, since there are too many dependencies to those classes</p>