-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Problem with multi-exception catch blocks #421
Comments
@jpstotz can you suggest how to better restore such code?
public void test() {
try {
System.out.println("Test");
} catch (ProviderException e) {
throw new RuntimeException(e);
} catch (DateTimeException e) {
throw new RuntimeException(e);
}
}
|
My personal preference would be to re-generate the multi-exception catch block as it is the original code. Additionally readability is much better especially if the catch block becomes larger or the number of catched exceptions is higher than two. From what I have read on StackOverflow multi-exception catch block works on Android since API 19, I don't know why Android Studio limits it to 26+. That some people may run into issues when trying to re-compile the Jadx generate decompiled project is a draw-back caused by the original source, not by Jadx. Anyway I am fine with any of those three options. Just implement the option that you prefer respectively requires the least effort. |
@jpstotz I added support for multi-exceptions in a catch block. Only simple cases for now. |
@skylot Thank you very much. |
Jadx currently has problems with catch blocks that catch more than one exception like this one:
See the attached minimal example app (in the
MainActivity
class):app-debug.apk.zip
Note: Even if Android Studio only allows such code if minSdk is 26 or higher or the method is annotated like my example I have seen Android apps with minSdk 15 that use such code without annotation (e.g. Whatsapp).
The text was updated successfully, but these errors were encountered: