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

[core] [regression] Compilation error due to code duplication #1303

Closed
nitram84 opened this issue Dec 8, 2021 · 2 comments
Closed

[core] [regression] Compilation error due to code duplication #1303

nitram84 opened this issue Dec 8, 2021 · 2 comments
Labels
Milestone

Comments

@nitram84
Copy link
Contributor

nitram84 commented Dec 8, 2021

I found a regression between jadx-1.2.0-b1486-9744547f (ok, version used java-convert for decompilation) and jadx-1.3.0.213-6e8baef9 (failure with java-convert)
Tested with openjdk8.

Sample:

public class Test1 {

  public Integer calcValue(final Integer i) {
    if (i == null) {
      return null;
    }
    Integer res = null;
    try {
      if (i == 5) {
        res = 4;
      } else {
        res = 9;
      }
    }
    catch (final Exception ex) {
      logError(ex);
    }
    return res;
  }

  private void logError(Exception ex) {
  }
}

This is the decompilation result for jadx-1.3.0.213-6e8baef9 with --use-dx (Thank you for this flag!):

public class Test1 {
    public Integer calcValue(Integer i) {
        Integer res;
        if (i == null) {
            res = null;
            return null;
        }
        res = null;
        try {
            if (i.intValue() == 5) {
                return 4;
            }
            return 9;
        } catch (Exception ex) {
            logError(ex);
            return res;
        }
        logError(ex); // <--- compilation error due to code duplication
        return res;
    }

    private void logError(Exception ex) {
    }
}

Java-input works fine, so this is a dex only issue.

Suggested tags: try-catch, code-duplication, java-convert
Of course this sample can be used in unit tests.

@nitram84 nitram84 added bug Core Issues in jadx-core module labels Dec 8, 2021
@skylot
Copy link
Owner

skylot commented Dec 8, 2021

@nitram84 thanks!
Here jadx generate incorrect CFG for try/catch, so it is funny that jadx managed to generate something.
Also, with java-input I also got incorrect code: int res = null; this issue with type inference 🤦

And as a side note: I don't really need info about working version for regressions, I only check latest master branch, so you don't need to find working version :)

@skylot
Copy link
Owner

skylot commented Dec 9, 2021

Fixed. Type issue was caused by deboxing pass.

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

2 participants