Behaviour of Analyzer and SimpleVerifier

Kasra Faghihi <[email protected]> Tue, 21 Aug 2018 11:19:26 -0700
Newsgroups gmane.comp.java.objectweb.asm
Message-ID <CAERR1vkti7YN9-jeChBzJ6zZ_4JChhg0nRSUYGD7QRr8R=+Y4A@mail.gmail.com>
Can someone please help me understand Analyzer/SimpleVerifier. It isn't
working the way I expect it to. Either this is a bug or I've misunderstood
how things should work.



Take the following method...

public class Issue84Test implements Coroutine {

    public boolean allInstrum = false; // MUST BE PUBLIC

    public void run(Continuation c) {
        final String tag = new String("run()");
        if (!allInstrum) {
            final Long i = echo();
        } else {
            final List<Integer> i = echo(c, 1);
        }
        echo(c, 2);
    }

   ...
}




Once you compile it using Oracle JDK and dump it through ASM, this is the
output...

   L0
    LINENUMBER 11 L0
    NEW String
    DUP
    LDC "run()"
    INVOKESPECIAL String.<init>(String) : void
    ASTORE 2
   L1
    LINENUMBER 12 L1
    ALOAD 0: this
    GETFIELD Issue84Test.allInstrum : boolean
    IFNE L2
   L3
    LINENUMBER 13 L3
    ALOAD 0: this
    INVOKESPECIAL Issue84Test.echo() : Long
    ASTORE 3
   L4
    LINENUMBER 14 L4
    GOTO L5
   L2
    LINENUMBER 15 L2
   FRAME APPEND [String]
    ALOAD 0: this
    ALOAD 1: c
    ICONST_1
    INVOKESTATIC Integer.valueOf(int) : Integer
    INVOKESPECIAL Issue84Test.echo(Continuation, Object) : List
    ASTORE 3
   L5
    LINENUMBER 17 L5
   FRAME SAME
    ALOAD 0: this
    ALOAD 1: c
    ICONST_2
    INVOKESTATIC Integer.valueOf(int) : Integer
    INVOKESPECIAL Issue84Test.echo(Continuation, Object) : List
    POP
   L6
    LINENUMBER 18 L6
    RETURN
   L7
    LOCALVARIABLE this Issue84Test L0 L7 0
    LOCALVARIABLE c Continuation L0 L7 1
    LOCALVARIABLE tag String L1 L7 2
    MAXSTACK = 3
    MAXLOCALS = 4




The problem here is that both "Long i" in the if block and "List i" in the
else block share the same LVT index (index=3).

Analyzer/SimpleVerifier seems to be identifying the final line of the
method as having a "List" at LVT index=3, but technically it could be
either "Long" or "List" (depending on whether the if block was executed or
the else block was executed). For the last line, shouldn't
Analyzer/SimpleVerifier give back a type of Object for LVT index=3? Object
is the parent of both Long and List.

This relates to coroutines issue#84. Please let me know if I'm not
explaining things clearly.


-- 
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws