Annotation Type EnsuresLTLengthOf
-
@Documented @Retention(RUNTIME) @Target({METHOD,CONSTRUCTOR}) @PostconditionAnnotation(qualifier=LTLengthOf.class) @InheritedAnnotation @Repeatable(List.class) public @interface EnsuresLTLengthOfIndicates that the value expressions evaluate to an integer whose value is less than the lengths of all the given sequences, if the method terminates successfully.Consider the following example, from the Index Checker's regression tests:
where@EnsuresLTLengthOf(value = "end", targetValue = "array", offset = "#1 - 1") public void shiftIndex(@NonNegative int x) { int newEnd = end - x; if (newEnd < 0) throw new RuntimeException(); end = newEnd; }endis annotated as@NonNegative @LTEqLengthOf("array") int end;This method guarantees that
endhas type@LTLengthOf(value="array", offset="x - 1")after the method returns. This is useful in cases like this one:
The first call topublic void useShiftIndex(@NonNegative int x) { // :: error: (argument.type.incompatible) Arrays.fill(array, end, end + x, null); shiftIndex(x); Arrays.fill(array, end, end + x, null); }Arrays.fillis rejected (hence the comment about an error). But, after callingshiftIndex(x),endhas an annotation that allows theend + xto be accepted as@LTLengthOf("array").- See Also:
EnsuresLTLengthOfIf,LTLengthOf- See the Checker Framework Manual:
- Index Checker
-
-
Required Element Summary
Required Elements Modifier and Type Required Element Description java.lang.String[]targetValueSequences, each of which is longer than the each of the expressions' value on successful method termination.java.lang.String[]valueThe Java expressions that are less than the length of the given sequences on successful method termination.
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String[]offsetThis expression plus each of the value expressions is less than the length of the sequence on successful method termination.
-
-
-
Element Detail
-
value
@JavaExpression java.lang.String[] value
The Java expressions that are less than the length of the given sequences on successful method termination.- See the Checker Framework Manual:
- Syntax of Java expressions
-
-
-
targetValue
@JavaExpression @QualifierArgument("value") java.lang.String[] targetValue
Sequences, each of which is longer than the each of the expressions' value on successful method termination.
-
-
-
offset
@JavaExpression @QualifierArgument("offset") java.lang.String[] offset
This expression plus each of the value expressions is less than the length of the sequence on successful method termination. Theoffsetelement must ether be empty or the same length astargetValue.- Returns:
- the offset expressions
- Default:
- {}
-
-