a wrong hint from netbeans


https://netbeans.org/bugzilla/show_bug.cgi?id=262707

public class User {

    public void setUsername(final String username) {
        if (this.username != null) {
            throw new IllegalArgumentException(
                    "already has a username");
        }
        this.username = username;
    }

    @NotNull
    private String username;
}

NetBeans shows a hint for the line 4.

Unnecessary test for null – the expression is never null

That’s simply wrong. NetBeans see the @NotNull and he (or she) thinks the field will never null at any time.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s