cfr icon indicating copy to clipboard operation
cfr copied to clipboard

CFR tries to convert integer variables to short ones

Open AIRTEspresso opened this issue 2 years ago • 2 comments

CFR version

CFR version: 0.152

Compiler

Java openJDK, version: 11.0.13

Description

Here is another case that CFR may generate invalid Java code. In this example, CFR used the var 'int n' for value 14756, and after that 'n' is assigned to the short arrays, where the error is. I think it is a minor mistake and CFR can easily solve it by adding a cast expression here, right? The total case is available at error example and I hope it can be helpful.

Example

The source code:

class Test {
    int N;
    {
        short s1 = 14756 , sArr[][][]= new short[N][N][N];
        int i15 = 67;
        sArr[i15][i15][i15]= s1;
    }
}

The code decompiled by CFR:

class Test {
    int N;

    Test() {
        int n = 14756;
        short[][][] sArray = new short[this.N][this.N][this.N];
        int n2 = 67;
        sArray[n2][n2][n2] = n;
    }
}

AIRTEspresso avatar Apr 24 '22 21:04 AIRTEspresso

@AIRTEspresso Do you have a way to generate random java code samples?

Kroppeb avatar May 03 '22 15:05 Kroppeb

@Kroppeb Yes, I use the JavaFuzzer: it can be found in Github JavaFuzzer

AICT20 avatar May 15 '22 00:05 AICT20