Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning if @MonotonicNonNull apply to static fields #949

Open
Ao-senXiong opened this issue Oct 21, 2024 · 0 comments
Open

Warning if @MonotonicNonNull apply to static fields #949

Ao-senXiong opened this issue Oct 21, 2024 · 0 comments

Comments

@Ao-senXiong
Copy link
Member

As the manual writes:

Use of @MonotonicNonNull on a static field is a code smell: it may indicate poor design. You should consider whether it is possible to make the field a member field that is set in the constructor.

However, the following code does not rise an warning:

import org.checkerframework.checker.nullness.qual.*;

public class Test {
    static @MonotonicNonNull  Object obj;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant