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:
Jacek Surazski 2019-10-17 15:23:15 -07:00 committed by Wouter van Oortmerssen
parent df3e8bf4a7
commit 8bfafc76de
1 changed files with 2 additions and 1 deletions

View File

@ -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 "
: "";
}