Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to fully structure code #360

Open
ambergorzynski opened this issue Sep 10, 2024 · 0 comments
Open

Unable to fully structure code #360

ambergorzynski opened this issue Sep 10, 2024 · 0 comments
Labels

Comments

@ambergorzynski
Copy link

CFR version

CFR 0.153-SNAPSHOT (3d1d0f4)

Compiler

openjdk 19.0.2

Description

I attempt to decompile a bytecode program with fairly simple (but impossible in Java) control flow. CFR outputs a Java program but includes a note 'Unable to fully structure code'. I got to this example while investigating another issue #359 that I assume is related. It seems to me that it should be possible to restructure this code for decompilation, although this is of course an atypical program!

The bytecode program looks like this:

.method public testCase([I)V
    .limit stack 3
    .limit locals 3

    iconst_0
    istore 2  

block_0:
    iload 2

    ifeq block_2
    goto block_1
            
block_1: 
    iload 2

    lookupswitch
        0: block_1
        1: block_2
        default: block_3

block_2:
    iload 2

    ifeq block_3
    goto block_3
            
block_3: 
    return

.end method

And the error from CFR is Unable to fully structure code. It cannot structure the code corresponding to block_2, which has two entry points (from block_0 and block_1).

/*
 * Decompiled with CFR 0.153-SNAPSHOT (3d1d0f4).
 */
public class TestCase {
    /*
     * Unable to fully structure code
     */
    public void testCase(int[] var1_1) {
        var2_2 = 0;
        if (var2_2 == 0) ** GOTO lbl-1000
        block4: while (true) {
            switch (var2_2) {
                case 0: {
                    continue block4;
                }
                case 1: lbl-1000:
                // 3 sources

                {
                    while (var2_2 != 0) {
                    }
                    break block4;
                }
            }
            break;
        }
    }
}

Example

example.zip

I attach the following:

  • program.j which is the original bytecode file
  • TestCase.class which is the class file associated with program.j
  • TestCase.java which is the decompiled output of CFR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant