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 #685

Closed
bagipro opened this issue Jun 8, 2019 · 7 comments
Labels
bug Core Issues in jadx-core module

Comments

@bagipro
Copy link
Collaborator

bagipro commented Jun 8, 2019

Example in class com.mercadolibre.android.cx.support.yoshi.p271a.p272a.C5475c (original class com.mercadolibre.android.cx.support.yoshi.a.a.c), but tons of examples

    public C5475c(com.mercadolibre.android.cx.support.yoshi.p271a.C5472a aVar, java.lang.String str, java.lang.String... strArr) {
        kotlin.jvm.internal.C12967g.m60316b(aVar, "intentResolver");
        kotlin.jvm.internal.C12967g.m60316b(str, "mainUrlExpression");
        kotlin.jvm.internal.C12967g.m60316b(strArr, "otherValidUrlExpressions");
        super(aVar, str, strArr);
    }

Usually all those statements before constructor and super constructor invocations are synthetic, and can be placed after invocs or even removed.

I know about that bug for a long time, but only now I noticed that it prevents binding resolutions :(

Example apk: https://drive.google.com/file/d/17kvvsl22CFsFzpcOUO4f0Szl_rdjTT1T/view?usp=sharing

@bagipro bagipro added bug Core Issues in jadx-core module labels Jun 8, 2019
@skylot
Copy link
Owner

skylot commented Jun 8, 2019

@sergey-wowwow thanks for noticing this!
You are right this is not correct Java code, and unfortunately java equivalent doesn't exist for that bytecode. And both suggested fixes (remove and move) change code semantics.
I think I will comment out these lines, so users will know that these checks exist, and Java code will be compilable.

TODO: use these strings as variable names :)

@bagipro
Copy link
Collaborator Author

bagipro commented Jul 3, 2019

@skylot
Can you please help? I've noticed a number of errors because of this issue :(

@skylot
Copy link
Owner

skylot commented Jul 3, 2019

@sergey-wowwow
I made a simple fix just for your example, it will not work in case with branching before super call (like if, for, etc) if you find sample for that please let me know )

@bagipro
Copy link
Collaborator Author

bagipro commented Jul 3, 2019

@skylot
Thanks! Yes, actually branched statements triggered the bug last times :) APK: https://drive.google.com/file/d/1W2gvSeK6zOh9fg7TyRU6dJytDADonbTm/view?usp=sharing

com.application.zomato.zomaland.ZLWebViewActivity$C4220b

        public /* synthetic */ C4220b(java.lang.String str, java.lang.String str2, java.lang.String str3, boolean z, int i, kotlin.p729e.p731b.C14068g gVar) {
            java.lang.String str4 = "";
            if ((i & 2) != 0) {
                str2 = str4;
            }
            if ((i & 4) != 0) {
                str3 = str4;
            }
            if ((i & 8) != 0) {
                z = false;
            }
            this(str, str2, str3, z);
        }

@bagipro
Copy link
Collaborator Author

bagipro commented Jul 5, 2019

And I actually never seen any cycles before constructor and super constructor calls, so it shouldn't be too much of changes

@skylot
Copy link
Owner

skylot commented Jul 5, 2019

@sergey-wowwow
Can you check latest master, I made several changes:

  • comment will cover complex structures (although some code can be not completely commented)
  • force convert conditions to ternary (like in your second case)
  • inline string constants (also needed for the second case)

Hope it will help :)

@bagipro
Copy link
Collaborator Author

bagipro commented Jul 6, 2019

@skylot
Thanks, that's perfect now :)

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