Commit 8bfafc76 authored by Jacek Surazski's avatar Jacek Surazski Committed by Wouter van Oortmerssen

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.
parent df3e8bf4
......@@ -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 "
: "";
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment