CheckClassAdapter is no longer transparent for MAXLOCALS
Expected Behavior
CheckClassAdapter
should not alter the input data. That is, for valid classes, the following should produce identical results:
cr.accept(new CheckClassAdapter(tcv), 0);
and
cr.accept(tcv, 0);
Current Behavior
As of v9.3 commit 9b880c26, MAXLOCALS
is incremented by 1
for static
methods. For example, using v9.2, the following is produced with or without CheckClassAdapter
// access flags 0x19
public final static main([Ljava/lang/String;)V
INVOKESTATIC run.$apply ()V
RETURN
MAXSTACK = 0
MAXLOCALS = 1
but with v9.3 & when using CheckClassAdapter
, the following is produced:
// access flags 0x19
public final static main([Ljava/lang/String;)V
INVOKESTATIC run.$apply ()V
RETURN
MAXSTACK = 0
MAXLOCALS = 2
Steps to Reproduce
Process a valid class with a static method using the following code. Uncomment one of the VERSION X lines.
byte[] classBytes = // ...valid-class-with-static-method...;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
ClassReader cr = new ClassReader(classBytes);
TraceClassVisitor tcv = new TraceClassVisitor(null, new Textifier(), pw);
// cr.accept(new CheckClassAdapter(tcv), 0); // VERSION 1
// cr.accept(tcv, 0); // VERSION 2
System.out.println(sw.toString());