mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-01 19:58:15 +00:00
Java: Don't annotate vector-of-tables item getters with @nullable. (#5562)
* Annotate getters with @Pure when --java-checkerframework is specified. Together with @Nullable, this allows users to use static analysis tools like CheckerFramework to catch NPEs caused by unset fields. * Don't annotate vector-of-tables item getters with @Nullable. Since Flatbuffers don't support null items in vectors of tables.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
df3e8bf4a7
commit
8bfafc76de
@@ -252,7 +252,8 @@ class GeneralGenerator : public BaseGenerator {
|
||||
|
||||
std::string GenNullableAnnotation(const Type &t) const {
|
||||
return lang_.language == IDLOptions::kJava && parser_.opts.gen_nullable &&
|
||||
!IsScalar(DestinationType(t, true).base_type)
|
||||
!IsScalar(DestinationType(t, true).base_type) &&
|
||||
t.base_type != BASE_TYPE_VECTOR
|
||||
? " @Nullable "
|
||||
: "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user