@Documented @Retention(value=RUNTIME) @Target(value={TYPE_USE,TYPE_PARAMETER}) @SubtypeOf(value={Unsigned.class,Signed.class}) public @interface SignednessGlb
Signed
or as Unsigned
. This
primarily applies to values whose most significant bit is not set SignedPositive
, and
thus the value has the same interpretation as signed or unsigned.
As a special case, the Signedness Checker also applies this annotation to manifest literals.
This permits a value like -1
or 255
or 0xFF
to be used in both signed and
unsigned contexts. The Signedness Checker has no way of knowing how a programmer intended a
literal to be used, so it does not issue warnings for any uses of a literal. (An alternate design
would require the programmer to explicitly annotate every manifest literal whose most significant
bit is set. That might detect more errors, at the cost of much greater programmer annotation
effort.)
The programmer should not write this annotation. Instead, the programmer should write Signed
or Unsigned
to indicate how the programmer intends the value to be interpreted.
For a value whose most significant bit is not set and different clients may treat it differently
(say, the return value of certain library routines, or certain constant fields), the programmer
should write @
SignedPositive
instead of @SignednessGlb
.
The "Glb" in the name stands for "greatest lower bound", because this type is the greatest
lower bound of the types Signed
and Unsigned
; that is, this type is a subtype of
both of those types.
SignedPositive