title: Load ASM generated Class while runtime
body: <p>I wrote some Bytecode via ASM (The generated Class implements some known Interface). </p>
  
  <p>I also have some dependencies on other classes. </p>
  
  <p>Now I want to hook the byte array up into some Class. </p>
  
  <p>How can I load the class from the byte array? </p>
  
  <p>Right now I get NoClassDefFoundError: IllegalName: core/selecter/ObjectSelector/codegen/testClass.class</p>
  
  <p>I use this Code to load the class: </p>
  
  <pre><code>@SuppressWarnings("unchecked")
  private static &lt;T&gt; SelectorAccess&lt;T&gt; createNewOrNull(byte[] bytesOfClass, String name) {
      try {
          return (SelectorAccess&lt;T&gt;) new ClassLoader() {
              public Class&lt;?&gt; defineClass(byte[] bytes) {
                  return super.defineClass(name.concat(".class"), bytes, 0, bytes.length);
              }
          }.defineClass(bytesOfClass).newInstance();
      } catch (InstantiationException | IllegalAccessException e) {
          e.printStackTrace();
          return null;
      }
  }
  </code></pre>
  
  <p>I think it is because my ClassLoader doesnt know the dependencies of my class? </p>
  
  <p>How can I avoid this problem? </p>