title: JVM: Invalid index 1 in LocalVariableTable
body: <p>I am trying to compile the following code using a custom compiler:</p>
  
  <pre><code>public static void main([String] args)
  {
      long i = 2L
      i *= 2L
      System out println i
  }
  </code></pre>
  
  <p>The result of the compilation is, when using <code>javap</code>, this Bytecode:</p>
  
  <pre><code>  public static void main(java.lang.String[]);
      descriptor: ([Ljava/lang/String;)V
      flags: ACC_PUBLIC, ACC_STATIC
      Code:
        stack=3, locals=2, args_size=1
           0: ldc2_w        #14                 // long 2l
           3: lstore_1      
           4: lload_1       
           5: ldc2_w        #14                 // long 2l
           8: lmul          
           9: lstore_1      
          10: getstatic     #21                 // Field java/lang/System.out:Ljava/io/PrintStream;
          13: lload_1       
          14: invokevirtual #27                 // Method java/io/PrintStream.println:(J)V
          17: return        
        LocalVariableTable:
          Start  Length  Slot  Name   Signature
              0      17     1     i   J
              0      17     0  args   [Ljava/lang/String;
      MethodParameters:
        Name                           Flags
        args
  </code></pre>
  
  <p>However, when I try to run the Bytecode, the JVM throws a <code>ClassFormatError</code> that reads <code>Invalid index 1 in LocalVariableTable</code>. Is this related to the fact that in the LocalVariableTable, slot 1 comes before slot 0?</p>
  
  <p><strong><em>EDIT</em></strong>:</p>
  
  <p>If I change the <code>long</code> variable to an <code>int</code>, the JVM does not complain at all, even if the LocalVariableTable is still unsorted:</p>
  
  <pre><code>  public static void main(java.lang.String[]);
      descriptor: ([Ljava/lang/String;)V
      flags: ACC_PUBLIC, ACC_STATIC
      Code:
        stack=2, locals=2, args_size=1
           0: iconst_2      
           1: istore_1      
           2: iload_1       
           3: iconst_2      
           4: imul          
           5: istore_1      
           6: getstatic     #19                 // Field java/lang/System.out:Ljava/io/PrintStream;
           9: iload_1       
          10: invokevirtual #25                 // Method java/io/PrintStream.println:(I)V
          13: return        
        LocalVariableTable:
          Start  Length  Slot  Name   Signature
              0      13     1     i   I
              0      13     0  args   [Ljava/lang/String;
      MethodParameters:
        Name                           Flags
        args
  </code></pre>