leibnitz27 / cfr

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

Negative array sizes are not correctly decompiled #212

Closed x4e closed 3 years ago

x4e commented 3 years ago

CFR version

CFR 0.151-SNAPSHOT (00f0a88)

Compiler

javac 15.0.1

Description

CFR will not properly decompile initiation of negative sized arrays.

Example

Example:

try {
    String[] stringArray = new String[-5];
    System.out.println("I will never be reached");
} catch (NegativeArraySizeException e) (
    System.out.println("I will always be reached");
}

will be decompiled as:

try {
    String[] stringArray = new String[]{};
    System.out.println("I will never be reached");
} catch (NegativeArraySizeException e) (
    System.out.println("I will always be reached");
}

which is of course not equivalent.

leibnitz27 commented 3 years ago

Hah, awesome. Inadvertently resugaring as an anonymous array. Great find!

x4e commented 3 years ago

Thanks :)