4 ms·
You can try checkerframework [1], which uses annotations to perform extra typechecking at compile time, including nullable/not-nullable checks. Works properly
by mrighele 7y ago
You can try checkerframework [1], which uses annotations to perform extra typechecking at compile time, including nullable/not-nullable checks.
Works properly altough it has a few issues: the biggest is that support is still stuck at java 8, and the framework is sometimes not smart enough to see that you already checked if a nullable field is null or not and you can safely use it.
[1] https://checkerframework.org/ https://checkerframework.org/
- ygra 7y agoAnnotations don't work for local variables, though. So you only get nullability checking around calling methods and accessing fields, right?
- mrighele 7y agoAnnotations in general do work for local variables, although this is specified on a per-annotation basis. If I remember correctly, for example, the @NotNull annotation in javax.validation.constraints cannot be used for a local variable, but the one provided by the checkerframework can.