title: JVM Verify Error 'Illegal type at constant pool'
body: <p>I am currently writing my own compiler and I am trying to compile the following code:</p>
  
  <pre><code>List[String] list = List("a", "b", "c", "d")
  list stream map((String s) =&gt; s.toUpperCase())
  System out println list
  </code></pre>
  
  <p>The compiler has no problem parsing, linking or compiling the code, but when it comes to executing it, the JVM throws the following error:</p>
  
  <pre><code>java.lang.VerifyError: Illegal type at constant pool entry 40 in class dyvil.test.Main
  Exception Details:
    Location:
      dyvil/test/Main.main([Ljava/lang/String;)V @29: invokevirtual
    Reason:
      Constant pool index 40 is invalid
    Bytecode:
      ...
  </code></pre>
  
  <p>I tried to use <code>javap</code> to find the problem, and this is the instruction <code>@29</code>:</p>
  
  <pre><code>29: invokevirtual #40 // InterfaceMethod java/util/Collection.stream:()Ljava/util/stream/Stream;
  </code></pre>
  
  <p>And the entry in the Constant Pool (also using <code>javap</code>):</p>
  
  <pre><code>#37 = Utf8               stream
  #38 = Utf8               ()Ljava/util/stream/Stream;
  #39 = NameAndType        #37:#38 // stream:()Ljava/util/stream/Stream;
  #40 = InterfaceMethodref #36.#39 // java/util/Collection.stream:()Ljava/util/stream/Stream;
  </code></pre>
  
  <p>When opening the class with the Eclipse Class File Viewer, the line where <code>@29</code> should be reads:</p>
  
  <pre><code>Class Format Exception
  </code></pre>
  
  <p>and all following instructions are not shown anymore (except for Locals, ...). However, the ASM Bytecode Plugin writes</p>
  
  <pre><code>INVOKEVIRTUAL java/util/Collection.stream ()Ljava/util/stream/Stream;
  </code></pre>
  
  <p>at that line, which appears to be valid. What am I doing wrong / missing here?</p>