title: CtClass.toClass throws an exception with message 'null'
body: <p>Steps i perform to create dynamic class is as follows:</p>
  
  <pre><code>      try
        {
  
              classLoader = Class.forName("org.yaddayadda.DynamicClass" + genericType.getName().toLowerCase() + uniqueID);
          }
          catch (ClassNotFoundException classNotFoundException)
          {
          }
  
          if (classLoader == null)
          {
              dynamicClass = pool.get("org.yaddayadda.DynamicClass");
              dynamicClass.defrost();
              dynamicClass.replaceClassName("org.yaddayadda.DynamicClass","org.yaddayadda.DynamicClass"+ genericType.getName().toLowerCase() + uniqueID);
  
              dynamicClass.defrost();
  
  
              CtMethod readObject = dynamicClass.getDeclaredMethod("Method1");
              CtMethod writeObject = dynamicClass.getDeclaredMethod("Method2");
  
              StringBuffer method1= new StringBuffer();
              StringBuffer method2= new StringBuffer();
  
              GenerateDynamicCode.generateCode(genericType, method1, method2);
  
              writeObject.insertAt(1, method1.toString());
              readObject.insertAt(1, method2.toString());
  
              //This is where the exception is thrown
              classLoader = dynamicClass.toClass();
          }
  </code></pre>
  
  <p>I first try to check if the class already exists in <code>ClassPool</code> if not then i proceed on to creating a class. Defrost is done for just a fail-safe mechanism. The Exception comes when the method <code>toClass</code> is called <code>dynamicClass.toClass();</code></p>
  
  <p>The Exception is as follows</p>
  
  <pre><code>    Exception Message: null
      Stack Trace: 
      sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
      sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
      java.lang.reflect.Method.invoke(Unknown Source)
      javassist.ClassPool.toClass2(ClassPool.java:1102)
      javassist.ClassPool.toClass(ClassPool.java:1083)
      javassist.ClassPool.toClass(ClassPool.java:1032)
      javassist.ClassPool.toClass(ClassPool.java:990)
      javassist.CtClass.toClass(CtClass.java:1125)
      This Class
  </code></pre>
  
  <p>What is the reason of the above exception and what can be done to avoid it ?</p>