This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Summary: | "Unnecessary test for null" with asserts | ||
---|---|---|---|
Product: | java | Reporter: | terje7601 |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | NEW --- | ||
Severity: | normal | ||
Priority: | P3 | ||
Version: | 8.1 | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | |||
Bug Blocks: | 249320 |
Description
terje7601
2015-09-30 11:49:47 UTC
In general asserts are put into the code to declare invariants which the programmer thinks should be true. By inserting an assert statement, the programmer explicitly says the variable should not be null after, and the IDE should work with that information. The actual runtime checks are irrelevant -- the code as it is written is broken. One can use assert to trigger debugging code, like boolean debug = false; assert debug = true; if (debug) { ... } or similar thing, but I think these are rather misuses of the assert statement. In the experimental implementation of issue #249320, several modes to analyze asserts are available in the analysis engine, including your approach - but no UI :) so I'll keep this defect as a reminder to provide user option to tune the analysis. |