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] Constructor and super constructor invocations should be first statements (update) #704

Closed
bagipro opened this issue Jul 9, 2019 · 3 comments
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Jul 9, 2019

Checks before report

  • [+] check latest unstable build (maybe issue already fixed)
  • [+] search existing issues by exception message
    (for example JadxRuntimeException: Can't find immediate dominator for block)
  • [+] check Troubleshooting Q&A section on wiki

Describe error
Original thread: #685

Can you place (super) constructor call on the first place? I've noticed that anonymous classes are changed to inner classes, but used external variables are not accessible anymore. Example (class com.paypal.android.p2pmobile.wallet.common.fragments.ThreeDsWebViewFragment$C35854)

    /* renamed from: com.paypal.android.p2pmobile.wallet.common.fragments.ThreeDsWebViewFragment$4 */
    class C35854 extends android.os.CountDownTimer {
        final /* synthetic */ java.lang.String val$password; // <<< is not initialized anymore

        /* JADX WARN: Illegal instructions before constructor call commented (this can break semantics) */
        C35854(long j, long j2, java.lang.String str) {
            // this.val$password = str;
            super(j, j2);
        }

APK: https://drive.google.com/file/d/1CSo_sZ71WsM3WvGw2VzG7xnkqpUO3GSJ/view?usp=sharing

@bagipro bagipro added bug Core Issues in jadx-core module labels Jul 9, 2019
@bagipro
Copy link
Collaborator Author

bagipro commented Jul 11, 2019

@skylot
You already added code to process ternary ops, can you do the same for string concats? Example in the same APK, class com.paypal.android.foundation.activity.operation.ActivityDetailsRetrieveOperation

    protected ActivityDetailsRetrieveOperation(ActivityItem.Id id, ActivityDetailsRequestParamsHelper activityDetailsRequestParamsHelper) {
        // StringBuilder sb = new StringBuilder();
        // sb.append("activity-details/");
        // sb.append(id.getValue());
        super(sb.toString(), ActivityItem.class, activityDetailsRequestParamsHelper);
        this.f13703a = id.getActivityType();
    }

it could be changed to

        super("activity-details/" + id.getValue(), ActivityItem.class, activityDetailsRequestParamsHelper);

or

        super(new StringBuilder().append("activity-details/").append(id.getValue()).toString(), ActivityItem.class, activityDetailsRequestParamsHelper);

@bagipro
Copy link
Collaborator Author

bagipro commented Jul 11, 2019

And also variable declarations are still kept before constructor calls, file com/paypal/android/foundation/core/model/MutableDataObject.java

    public MutableDataObject(android.os.Parcel parcel) {
        org.json.JSONObject jSONObject;
        org.json.JSONObject jSONObject2;
        this();

@skylot
Copy link
Owner

skylot commented Jul 21, 2019

All cases fixed.
And now instead of commenting code I just move constructor call to the top of the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

2 participants