@Documented @Retention(value=RUNTIME) @Target(value=FIELD) public @interface BorrowedInRegion
allowsReturn
attribute to true and we have write access to its complete state.
A @BorrowedInRegion field must be final and cannot be
static.
This annotation differs from Borrowed only with regard to the region
the state referenced by the annotated field is mapped into. This annotation
declares that the Instance region of the object referenced by the
annotated field is mapped into a named region of the object that contains the
annotated field. Borrowed maps the state into the Instance
region of the object that contains the annotated field.
Therefore, the two
annotations below on the friends field are equivalent.
@Borrowed
private final Set<Person> friends; // initialized in constructor
@BorrowedInRegion("Instance")
private final Set<Person> friends; // initialized in constructor
In addition, a more complex syntax is allowed where regions of the object referenced
by the annotated field are explicitly mapped to regions of the
object that contains the annotated field. Using this syntax the annotation below is
equivalent to the two previous examples.
@BorrowedInRegion("Instance into Instance")
private final Set<Person> friends; // initialized in constructor
This syntax should be rare in practice, however we show an example of its use
in the Examples section below.
Borrowed fields are not currently assured by analysis.
Borrowed| Modifier and Type | Optional Element and Description |
|---|---|
String |
value
The value of this attribute must conform to the following grammar (in Augmented Backus–Naur
Form):
|
public abstract String value
value = regionSpecification / regionMapping *("," regionMapping)
regionMapping = simpleRegionSpecification "into" regionSpecification
regionSpecification = simpleRegionSpecificaion / qualifiedRegionName
simpleRegionSpecification = IDENTIFIER ; Region of the class being annotated
qualifedRegionName = IDENTIFIER *("." IDENTIFIER) : IDENTIFER ; Static region from the named, optionally qualified, class
IDENTIFIER = Legal Java Identifier
In A into B, the first RegionSpecification is relative to the
object referenced by the field; the second is relative to the object that
contains the field.
Copyright © 2012 Surelogic, Inc.. All Rights Reserved.