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

predictNullPointerExceptions is enabled when not optimizing aggressively #374

Open
epicblue-dev opened this issue Nov 30, 2023 · 2 comments

Comments

@epicblue-dev
Copy link

After upgrading from 7.2 to 7.4.1, we notice the generation of throw new NullPointerException() for statements that use a field injected by Spring DI.

Commit 3445fa0 shows how the predictNullPointerExceptions feature is introduced. Apparently, predictNullPointerExceptions is set to true when not optimizing aggressively, and is omitted when you do optimize aggressively.
This seems counterintuitive. We don't want aggresive optimization, but these incorrect throw new NullPointerException() statements make our application crash.

Our only way forward now is to don't optimize anything with -dontoptimize? 🤷

@tvoc-gs
Copy link
Contributor

tvoc-gs commented Nov 30, 2023

Thank you for reporting this.

You should be able to work around this by disabling optimization for the affected method(s), i.e.:

-keep,includecode class <affectedclass> {
    <affectedmethod>;
}

@epicblue-dev
Copy link
Author

Thank you for your answer. As we have a very large application, this happens in many hundreds of places. This workaround would require a lot of time to implement, and developers would have to think about ProGuard optimization when they write code.

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

No branches or pull requests

2 participants