I have some code that looks like this:
The statement "result.add(SOME_CONSTANT)" is highlighted with the
warning "Method invocation '...' may produce 'NullPointerException'".
If you follow the logic of the method you can see that the "result"
variable will always be non-null. But the inspection can't see this
because it doesn't understand the link between the assertion that the
"items" list is not empty and that iterating over that "items" list will
assign a non-null value to the "result" variable.
Would it be possible to improve the inspection to understand this?
Gordon Tyler (Software Developer)
Quest Software <http://java.quest.com/>
260 King Street East, Toronto, Ontario M5A 4L5, Canada
Voice: (416) 933-5046 | Fax: (416) 933-5001