title: How to make an abstract class non-abstract with Javassist?
body: <p>In a small framework I am building, I would like to change certain abstract classes to non-abstract using Javassist.
  I already transformed all the abstract methods in non-abstract ones implementing the dynamically generated code I need. But I have not yet succeed in making the class non-abstract.
  What I have tried is something similar to this:</p>
  
  <p>Let's say <code>c</code> is the class I would like to make non abstract. So I have written:</p>
  
  <pre><code>public void instrument(Class c) {
      ...//some ignored exception management
      CtClass ctClass = ClassPool.getDefault().get(c.getName());
      ctClass.setModifiers(c.getModifiers() &amp; ~Modifier.ABSTRACT);  
      return ctClass.toClass().newInstance();
  }
  </code></pre>
  
  <p>However, the call to:</p>
  
  <pre><code>ctClass.toClass();
  </code></pre>
  
  <p>is raising the following <code>CannotCompileException</code>: </p>
  
  <pre><code>"attempted  duplicate class definition for name: &lt;class_name&gt;."
  </code></pre>
  
  <p>This is because the class has already been loaded, since I am invoking its <code>getName</code> method. It seems to me this is the only mechanism I have to get a <code>CtClass</code> from an existing class, but please someone tell me if that is not correct. Hardcoding the name of the class instead of calling its <code>getName</code> method is far from been an ideal solution, given that I need to apply this routine to many classes.</p>
  
  <p>Any workaround to do this ?. If it is not possible at all I will dynamically generate a new class that extends the abstract class, implements its constructors, and the abstract method of all its ancestors (a bit more complicated, so I would be very happy if I succeed just making the original class non-abstrat instead).</p>