blob: d9839eee1b245e3f378af03918eb01395587526f [file] [view]
---
name: general/include-detail-messages-in-java-assertions
rubric: readability
severity: nit
---
**Rule.** In Java assertions, provide an informative detail message
(`assert <condition> : <message>;`) for state invariants, preconditions, and
lifecycle checks so that assertion failures provide clear diagnostic context.
**Why.** Java assertions in Chromium are enabled in debug builds and reported
via a silent assertion reporter on Canary, with R8 stripping assertion
expressions and messages in release builds. Bare assertions throw an
AssertionError without detail, making test failure triage and Canary crash
report analysis significantly harder.
## Examples
Bad:
```cpp
assert sLauncherHandler == null;
```
Good:
```cpp
assert sLauncherHandler == null : "ScopedBatchUpdate was already activated.";
```