Annotation Interface ThrowsUnsupportedOperation
UnsupportedOperationException,
as AbstractList.set() does.
Write this annotation on a skeletal implementation, such as one in
java.util.AbstractList, that a subclass is expected to override. A subclass that inherits the
implementation without overriding it does not support the operation, even if the subclass
declares that it does. The Modifiability Checker issues an error for such a subclass; without
this annotation, it could not, because the body of an inherited method is compiled separately and
the checker sees only its signature.
The Modifiability Checker verifies the annotation on any method it compiles: the body must be
exactly throw new UnsupportedOperationException(...).
Do not write this annotation on a method that throws UnsupportedOperationException
only because some other method does, such as AbstractList.add(E), whose body is
add(size(), e). A subclass that overrides the other method makes such a method work.
- See the Checker Framework Manual:
- Modifiability Checker