New issue
Advanced search Search tips

Issue 922220 link

Starred by 1 user

Issue metadata

Status: Available
Owner: ----
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Bug



Sign in to add a comment

Java Style Guide: Discourage throwing IllegalStateException & NullPointerException

Project Member Reported by agrieve@chromium.org, Jan 15

Issue description

These kinds of exceptions are generally more appropriate as asserts so that they can be removed in release builds.
Where they are important to have in release builds, they should have their descriptions removed (if the description is a constant).

Good:
// Shouldn't do this.
throw new IllegalStateException();

Bad:
throw new IllegalStateException("Shouldn't do this.");

Okay:
throw new IllegalStateException(String.format("Value=%s", value));


Codebase has ~150 of them:
https://cs.chromium.org/search/?q=throw.*(IllegalStateException%7CIllegalArgumentException%7CNullPointerException)+-file:test+-file:third_party+lang:java+-file:cronet+-file:android_webview&sq=package:chromium&type=cs


If the java@ agrees this is a good change, we should:
1) Update style guide
2) Add a checkstyle warning (ignorable)
3) Fix up some existing instances
 

Comment 1 by agrieve@chromium.org, Yesterday (38 hours ago)

Labels: binary_size_team_q1_2019

Sign in to add a comment