leibnitz27 / cfr

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

Decompilation of boolean expressions with varargs method invocations fails #217

Closed nitram84 closed 3 years ago

nitram84 commented 3 years ago

CFR version

CFR 0.151-SNAPSHOT (b79446a) and CFR 0.150, so this is not a regression of recent changes

Compiler

openjdk8, openjdk11

Description

Decompilation of boolean expressions with varargs method invocations fails in some cases:

Example

public class CfrTest1 {

  private static boolean isValid(String... string) {
    return false;
  }

  protected static boolean b1;
  protected static final boolean isValid = b1 && isValid("test");
}

Second example:

public class CfrTest2 {

  public static boolean c(String... values) {
    return false;
  }

  public boolean isValid(int x) {
    return false;
  }

  protected int broken(int x) {
    int i = 0;
    boolean a = isValid(x) && c("test");
    boolean b = isValid(x + 1);

    if (a) {
      i = 0;
    } else if (b) {
      i = 1;
    }
    return i;
  }
}

These samples may be used as test cases for the cfr test suite.

Marcono1234 commented 3 years ago

Could you please fix the formatting of your example code? You have to use three backticks for code blocks, e.g.:

```java
class MyClass {
    ...
}
```
nitram84 commented 3 years ago

@Marcono1234 Thank you!

leibnitz27 commented 3 years ago

Nice, thanks.