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

Type Conversion Expression Lost in Constructor #342

Open
xxh160 opened this issue May 2, 2023 · 0 comments
Open

Type Conversion Expression Lost in Constructor #342

xxh160 opened this issue May 2, 2023 · 0 comments
Labels

Comments

@xxh160
Copy link

xxh160 commented May 2, 2023

Hi! I am doing some research based on CFR. I would like to report an issue that I encountered while using the CFR decompiler. Specifically, I found that the type conversion expression passed to a constructor is lost during decompilation.

Here is an example:

class T1 {
    public T1(byte b) {
    }
}

class Demo {
    public static void foo() {
        T1 t1 = new T1((byte) -70);
    }
}

After decompiling this code with CFR, the resulting code looks like this:

/*
 * Decompiled with CFR 0.153-SNAPSHOT (24c7433-dirty).
 */
class T1 {
    public T1(byte by) {
    }
}

class Demo {
    Demo() {
    }

    public static void foo() {
        T1 t1 = new T1(-70);
    }
}

As you can see, the type conversion expression (byte) is missing, which can cause compilation errors when trying to compile the decompiled code:

./Demo.java:9: error: incompatible types: possible lossy conversion from int to byte
        T1 t1 = new T1(-70);
                       ^
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
1 error

Would you please have a look at this? It is important for me!
Thanks a lot!

CFR version: CFR 0.153-SNAPSHOT (24c7433-dirty).
Javac version: openjdk 11.0.18 2023-01-17.
I also attach relative files and I hope they will be helpful: demo.zip.

@xxh160 xxh160 added the bug label May 2, 2023
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