title: How to avoid "Illegal type in constant pool" using "ldc_w <classname>" in Jasmin?
body: <p>I'm writing a compiler that generates Jasmin code and
  want to invoke a method that takes a Class as a parameter.</p>
  
  <pre><code>public class CTest
  {
      public static void main(String[] args)
          throws Exception
      {
          java.lang.reflect.Array.newInstance(CTest.class, 0);
      }
  }
  </code></pre>
  
  <p>So in Jasmin, I think that should be:</p>
  
  <pre><code>.class public CTest2
  .super java/lang/Object
  
  .method public static main([Ljava/lang/String;)V
      .limit stack 2
      .limit locals 1
      ldc_w CTest2
      iconst_0
      invokestatic java/lang/reflect/Array/newInstance(Ljava/lang/Class;I)Ljava/lang/Object;
      pop
      return
  .end method
  </code></pre>
  
  <p>When I assemble it and run it I get:</p>
  
  <p>Exception in thread "main" java.lang.VerifyError: (class: CTest2, method: main signature: ([Ljava/lang/String;)V) Illegal type in constant pool</p>
  
  <p>Looking at the disassembled code for both CTest.class (the Java version)
  and CTest2.class (the Jasmin version) with "javap -c -verbose"
  they both appear to set up the constant pool the same way:</p>
  
  <pre><code>const #2 = class        #16;    //  CTest
  const #16 = Asciz       CTest;
  
    0:   ldc_w   #2; //class CTest
  
  const #14 = Asciz       CTest2;
  const #17 = class       #14;    //  CTest2
  
    0:   ldc_w   #17; //class CTest2
  </code></pre>
  
  <p>I've fixed two bugs in Jasmin already, but I can't see what it's
  doing wrong when putting the class in the constant pool for "ldc_w"
  it puts classes in the constant pool for other instructions, like
  "new" and "anewarray" correctly.</p>
  
  <p>I've tried looking at the .class files with TraceClassVisitor in ASM,
  but it doesn't dump the constant pool.</p>
  
  <p>Any ideas what I can try next?</p>