Search code examples
javabytecodedecompiling

Odd pattern in Java bytecode


I've been looking at some Java bytecode, and I keep finding an odd pattern in it that I can't seem to translate into any reasonable Java construct:

    if ( <cond1> )
        goto Label;

    do {
        <code1>
Label:
        <code2>
    } while ( <cond2> );

Is there any reasonable Java construct that this can be decompiled to? All I can think of is very complicated patterns which introduce extra state to keep track of whether it is the first iteration of the loop or not.


Solution

  • for (init condition for which cond2 reduces to cond1; cond2; code1) {
      code2;
    }