title: ClassCircularityError thrown by ClassLoader.defineClass
body: <p>I'm loading classes using a custom class loader.  For the most part, everything works, but sometimes when I load particularly complex projects/libraries, I get a strange bug:</p>
  
  <pre><code>Exception in thread "main" java.lang.ClassCircularityError: 
    org/apache/commons/codec/binary/Hex
      at java.lang.ClassLoader.defineClass1(Native Method)
      at java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
      at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
      at my.custom.class.Loader.loadClass(...)
  </code></pre>
  
  <p>Looking at the Javadocs, I wouldn't expect <code>defineClass</code> to throw this particular error.  <code>org/apache/commons/codec/binary/Hex</code> is the class I'm trying to load. It's almost as if <code>defineClass</code> wants a copy of the class before it'll define the class - which makes no sense to me.</p>
  
  <p>Ideas?</p>