title: ASM 5: when initializing a ClassWriter, what is the difference between COMPUTE_MAXS and COMPUTE_FRAMES?
body: <p>I am the maintainer of <a href="https://github.com/fge/grappa" rel="noreferrer">grappa</a>. This package generates parsers at runtime from Java code by using ASM to generate a class extending your parser class.</p>
  
  <p>I have already migrated from ASM 4 to ASM 5, and from generating JVM 1.5 bytecode to generating JVM 1.6 bytecode, and now I have just succeeded in having it generate JVM 1.7 bytecode instead... except I have no idea <em>why</em> this works.</p>
  
  <p>Basically, I did the following:</p>
  
  <ul>
  <li>Changing the argument to the ClassWriter constructors; prior to that it was <code>new ClassWriter(ClassWriter.COMPUTE_MAXS)</code>, and it is now <code>new ClassWriter(ClassWriter.COMPUTE_FRAMES)</code></li>
  <li>Changing the first argument of each call to the <code>.visit()</code> method from <code>Opcodes.V1_6</code> to <code>Opcodes.V1_7</code>.</li>
  </ul>
  
  <p>Now, why I don't understand why it works for two reasons:</p>
  
  <ul>
  <li><p>I have several calls to <code>MethodVisitor</code>s which read:</p>
  
  <pre><code>mv.visitMaxs(0, 0); // trigger automatic computing
  </code></pre>
  
  <p>Does that mean that these instructions can be removed?</p></li>
  <li><p>At first I have only tried and <em>added</em> the <code>COMPUTE_FRAMES</code> argument to the <code>ClassWriter</code> constructors but it failed at one point for one of my tests in which I declare:</p>
  
  <pre><code>static class TestJoinParser
      extends EventBusParser&lt;Object&gt;
  {
      protected final JoinMatcherBuilder builder
          = join('a').using('b');
  }
  </code></pre>
  
  <p>And the error was:</p>
  
  <pre><code>java.lang.ClassFormatError: Arguments can't fit into locals
  </code></pre>
  
  <p>Given that it is an instance field I suppose it has to do with that particular argument being initialized in the constructor?</p></li>
  </ul>
  
  <p>Anyway, all my tests now work, I am in the process of trying heavier tests etc... But as my goal is to go further, I'd like to understand at least a little as to why my modifications worked at all...</p>