jadx icon indicating copy to clipboard operation
jadx copied to clipboard

[core] Weird if-else statements

Open bagipro opened this issue 2 years ago • 0 comments

Hey!

I've noticed weird conditions when decompiled. Let's assume that we have the following code:

    void test(String action) {
        if ("a".equals(action)) {
            do1();
        } else if ("b".equals(action)) {
            do2();
        } else if ("c".equals(action)) {
            do3();
        }
    }

However, it's always decompiled to

    void test(String action) {
        if ("a".equals(action)) {
            do1();
        } else if ("b".equals(action)) {
            do2();
        } else if (!"c".equals(action)) {
        } else {
            do3();
        }
    }

It includes not only string conditions, but all of them. Is there a way to make the decompiled code more pretty?

An example is in method com.samsung.android.aircommandmanager.AirCommandManager.AirCmdBroadcastReceiver.onReceive() in APK https://drive.google.com/file/d/1-awUDVr7qOf6ao_H7-f_bnWHgluavt7M/view?usp=sharing:

        } else if ("com.sec.android.facm.START_WIFI_SOCKET_CONNECT".equals(action)) {
            m369s(stringExtra, stringExtra2);
        } else if (!"com.sec.android.facm.START_WIFI_AP_CONNECT".equals(action)) {
        } else {
            m373o(stringExtra, stringExtra2);
        }

bagipro avatar Sep 18 '22 12:09 bagipro