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.
Say you have a method called ArgCheck.notNull(Object param, String paramName) that checks to see if a parameter is not null and throws an exception with paramName if it is. It would be great if one could annotate param in such a way that the ide knows that param cannot be null after this method is invoked or something like that. Another example: boolean foo(String bar){ if (StringUtilities.isBlank(bar)){ return false; } //logic int thing = bar.length(); //<- no null warning //more stuff }
I have an idea. You could add annotations for parameters. For example, with a method that returns a boolean and takes an object, you could annotate the argument with: @NullTrue or @NullFalse To tell the IDE what value gets returned when null is passed in. You could also add @NullException to indicate that an exception will be thrown if the item is null.
Yes, this would be useful. I plan, in the future, some metadata (perhaps distilled from annotations, but also should be specified in text files for e.g. 3rd party libraries). There's a lot what a method can do -- param may be known to be null, or nullable (sometimes null), the method may throw an exception, return a non-null or nullable ...