title: While loop in Java bytecode using ASM 4.0 does not work
body: <p>I'm writing a compiler for a language in Java bytecode using ASM 4.0. Executing the program causes it to crash. The relevant part of a stack trace is following:</p>
  
  <pre><code>java.lang.ArrayIndexOutOfBoundsException: 0
      at org.objectweb.asm.Frame.a(Unknown Source)
      at org.objectweb.asm.Frame.a(Unknown Source)
      at org.objectweb.asm.MethodWriter.visitMaxs(Unknown Source)
  </code></pre>
  
  <p>The problem is in a code for a while loop:</p>
  
  <pre><code>Label start = new Label();
  Label end = new Label();
  
  methodVisitor.visitLabel(start);
  generateCodeForACondition(condition, methodVisitor);
  
  methodVisitor.visitJumpInsn(IFEQ, end);
  generateCodeForABody(ws.getBody(), methodVisitor);
  methodVisitor.visitJumpInsn(GOTO, start);
  
  methodVisitor.visitLabel(end);
  </code></pre>
  
  <p>Fun fact: the code for my if/else statement is very similar to that of a while loop, however the if/else code works and the while loop code doesn't. It means that the methods generateCodeForACondition and generateCodeForABody both work properly.</p>
  
  <p>What could be the problem?</p>