leibnitz27 / cfr

This is the public repository for the CFR Java decompiler
https://www.benf.org/other/cfr
MIT License
2.06k stars 263 forks source link

Ternary Expression Causing Decompilation Type Error #349

Open xxh160 opened 1 year ago

xxh160 commented 1 year ago

CFR version

CFR 0.153-SNAPSHOT (24c7433-dirty)

Compiler

javac 11.0.20.1

Description

CFR may exhibit type errors in the decompilation of ternary expressions.

Example

Example code is as follows:

class T1 {
    public Object foo(boolean b) {
        Integer i1 = 1;
        return ((b) ? i1 : (Byte[]) new Object[] { (byte) -98 });
    }
}

The decompiled code is as follows:

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

    public Object foo(boolean bl) {
        Byte[] byteArray = Integer.valueOf(1);
        return bl ? byteArray : (Byte[])new Object[]{(byte)-98};
    }
}

Integer.valueOf(1) returns an int type instead of Byte[] type, which causes a compilation error.