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.
In Java 8: There is the class Optional<T> that stores a variable that may or may not be present. Assume you have: Optional<String> optional = someFunctionCall(); You do not know the content of it. Currently you can call optional.get() without problems, which may result in a NoSuchElementException. I suggest a check similar to null variable values, as the following: optional.isPresent() MUST be tested before you can call optional.get() to get rid of the warning. There is an edge case where someone may know that the Optional<T> has a value, by calling for example: Optional<String> optional = Optional.of("abc") However you could argue that in this case you should not be using an Optional at all, AND the warning can still be turned off per project.
Wow. This is a thing similar to possible NPE and data flow analysis, yet different. I need to think this through.