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 | ||
---|---|---|---|
Product: | java | Reporter: | zgabi |
Component: | Hints | Assignee: | Svata Dedic <sdedic> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | jo.navy, rosa_t |
Priority: | P3 | ||
Version: | 8.0.1 | ||
Hardware: | PC | ||
OS: | Windows 8 x64 | ||
Issue Type: | DEFECT | Exception Reporter: | |
Bug Depends on: | 249320 | ||
Bug Blocks: |
Description
zgabi
2014-06-23 21:10:20 UTC
reprducible The same error occures for the following code public void aFunction (Object a, Object b) { if (a == null ? b == null : b != null) { return; } if (a == null) { // unnecessary test for null appears here // do something } } If a is null and b not, the first test is false and the second is necessary. If I rewrite the first test as if ((a == null && b == null) || (a != null && b != null)) { The warning disappears but the value of a is tested twice *** Bug 251969 has been marked as a duplicate of this bug. *** *** Bug 247446 has been marked as a duplicate of this bug. *** The case in the original description is not possible to solve with the current algoritm. The 2nd case could be fixed though. Fixed in the experimental impl; wait for the umbrella issue to close. |