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

[feature] Concat constants #1014

Closed
bagipro opened this issue Nov 15, 2020 · 5 comments
Closed

[feature] Concat constants #1014

bagipro opened this issue Nov 15, 2020 · 5 comments

Comments

@bagipro
Copy link
Collaborator

bagipro commented Nov 15, 2020

Describe your idea:
Sometimes I see code such as

String value = "1" + "2";

Is that possible to implement a flag (or do it by default) to merge such constants? So after decompilation it would be

String value = "12";
@skylot
Copy link
Owner

skylot commented Nov 15, 2020

@bagipro sure this can be implemented.
But, did you know the reason why this happens? I mean, java compiler always concat constant strings, so this will not occur in normal java building pipeline. Did you see such cases in any open source projects, so I can trace the cause of the issue.

@bagipro
Copy link
Collaborator Author

bagipro commented Nov 15, 2020

@skylot
Probably because it's concatenated from different final fields, so the compiler replaces field references with their values, but doesn't concatenate. I will find such examples

@bagipro
Copy link
Collaborator Author

bagipro commented Nov 16, 2020

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

Class com.dsi.ant.channel.EventBufferSettings

    public java.lang.String toString() {
        return "Event Buffer Settings:" + " -Buffer Time: " + this.mBufferTimeMilliseconds + "ms";
    }

And with int, class com.dsi.ant.channel.EventBufferSettings

                android.util.Log.i(str, "Decoding version " + readInt2 + " AntContinuousScanController parcel with version " + 1 + " parser.");

skylot added a commit that referenced this issue Nov 16, 2020
@skylot
Copy link
Owner

skylot commented Nov 16, 2020

Done.
@bagipro thanks for samples.

@skylot skylot closed this as completed Nov 16, 2020
@bagipro
Copy link
Collaborator Author

bagipro commented Nov 16, 2020

@skylot
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants