title: Why is the Java 7 Bytecode Verifier complaining about this Stack Frame?
body: <p>I have a method which I have altered in a Java 7 (major version 51) class.  Using <code>javap</code>, I've looked at the bytecode and the Stack Frame Map.  Everything looks fine:</p>
  
  <pre><code>public int addOne(int);
  flags: ACC_PUBLIC
  Code:
    stack=2, locals=2, args_size=2
       0: iload_1
       1: iconst_0
       2: invokestatic  #50                 // Method isSomething:(I)Z
       5: ifeq          12
       8: iconst_0
       9: goto          13
      12: iconst_1
      13: iadd
      14: ireturn
  
  StackMapTable: number_of_entries = 2
       frame_type = 255 /* full_frame */
      offset_delta = 12
      locals = [ class test/Target, int ]
      stack = [ int ]
       frame_type = 255 /* full_frame */
      offset_delta = 0
      locals = [ class test/Target, int ]
      stack = [ int, int ]
  </code></pre>
  
  <p>This verifier throws this exception:</p>
  
  <pre><code>java.lang.VerifyError: Expecting a stackmap frame at branch target 12
  Exception Details:
    Location:
      test/Target.addOne(I)I @5: ifeq
    Reason:
      Expected stackmap frame at this location.
    Bytecode:
      0000000: 1b03 b800 3299 0007 03a7 0004 0460 ac
  </code></pre>
  
  <p>What's driving me crazy is that I had the compiler generate <em>the same code</em> from Java source, and it looks like this:</p>
  
  <pre><code>  public int addOne(int);
      flags: ACC_PUBLIC
      Code:
        stack=2, locals=2, args_size=2
           0: iload_1
           1: iconst_0
           2: invokestatic  #16                 // Method isSomething:(I)Z
           5: ifeq          12
           8: iconst_0
           9: goto          13
          12: iconst_1
          13: iadd
          14: ireturn
  
        StackMapTable: number_of_entries = 2
             frame_type = 76 /* same_locals_1_stack_item */
            stack = [ int ]
             frame_type = 255 /* full_frame */
            offset_delta = 0
            locals = [ class test/Target, int ]
            stack = [ int, int ]
  </code></pre>
  
  <p>Notice that the <em>only difference</em> in the stack frame map is that the synthetic map has all full frames -- but that shouldn't cause a difference.  Does anyone know why the verfier might not like my synthetic map?</p>