-
Notifications
You must be signed in to change notification settings - Fork 98
Description
On the API level, this likely means just adding a method Type.nullness() which returns an enum with 3 values (UNKNOWN, NULLABLE, NULL_RESTRICTED) . However, this also involves changing the serialization format.
Per https://openjdk.org/jeps/8303099:
In Java syntax, a nullness marker is used to indicate this property.
The type
Foo!is null-restricted: the value set excludesnull.The type
Foo?is nullable: the value set deliberately includesnull.By default, the nullness of the type
Foois unspecified: anullmay occur, but we don't know whether its presence is deliberate.
Signatureattributes have an updated grammar to allow!and?in types, as appropriate. Nullness is not encoded in method and field descriptors.However, to prevent pollution of fields, a new
NullRestrictedattribute allows a field to indicate that it does not allownullvalues.
This suggests that maybe we should add FieldInfo.isNullRestricted(), but let's leave that as an open question for now.