Skip to content

[core] Weird if-else statements #1674

@bagipro

Description

@bagipro

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);
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    CoreIssues in jadx-core modulebug

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions