@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR}) @InheritedAnnotation public @interface EnsuresLTLengthOfIf
As an example, consider the following method:
@EnsuresLTLengthOfIf( expression = "end", result = true, targetValue = "array", offset = "#1 - 1" ) public boolean tryShiftIndex(@NonNegative int x) { int newEnd = end - x; if (newEnd < 0) { return false; } end = newEnd; return true; }Calling this function ensures that the field
end
of the this
object is of type
@LTLengthOf(value = "array", offset = "x - 1")
, for the value x
that is passed as
the argument. This allows the Index Checker to verify that end + x
is an index into
array
in the following code:
public void useTryShiftIndex(@NonNegative int x) { if (tryShiftIndex(x)) { Arrays.fill(array, end, end + x, null); } }
LTLengthOf
,
EnsuresLTLengthOf
Modifier and Type | Required Element and Description |
---|---|
String[] |
expression
Java expression(s) that are less than the length of the given sequences after the method
returns the given result.
|
boolean |
result
The return value of the method that needs to hold for the postcondition to hold.
|
String[] |
targetValue
Sequences, each of which is longer than each of the expressions' value after the method
returns the given result.
|
public abstract String[] expression
public abstract boolean result
public abstract String[] targetValue
public abstract String[] offset
offset
element must ether be empty or the
same length as targetValue
.