com.surelogic
Annotation Type ReadOnly


@Documented
@Target(value={FIELD,CONSTRUCTOR,METHOD,PARAMETER})
public @interface ReadOnly

Declares that the parameter, receiver, return value, or field to which this annotation is applied cannot be used to mutate an object. A readonly variable differs from a variable to an immutable object in that readonly does not exclude the existence of references used for mutation. A readonly parameter, unlike a borrowed parameter for which mutation is not permitted, may be compromised/aliased. Thus we normally do not recommend variables be annotated readonly unless the callee wishes to retain a reference.

A Borrowed field may be annotated readonly to indicate that the field cannot be used for mutation.

It is a modeling error to annotate a variable of primitive type (e.g., @ReadOnly("return") public int getValue() would generate a modeling error). It is a modeling error to annotate a parameter if the parameter's type is primitive (e.g., public void setValue(@Unique int value) would generate a modeling error).

This annotation is not currently checked by analysis and is still experimental. It may be used for documentation purposes.

Semantics:

Parameter:

Return Value:

Field:

Examples:

Under development.

Javadoc usage notes:

This annotation may placed in Javadoc, which can be useful for Java 1.4 code which does not include language support for annotations, via the @annotate tag. One complication is that the parameter being annotated must be explicitly specified because the annotation can no longer appear in the context of the parameter declaration.
 /**
  * @annotate ReadOnly("a, b, c")
  */
 public void m1(Object a, Object b, Object c) { ... }
 
This annotation states that the three parameters are readonly. Alternatively, you can use several annotations as shown below.
 /**
  * @annotate ReadOnly("a")
  * @annotate ReadOnly("b")
  * @annotate ReadOnly("c")
  */
 public void m1(Object a, Object b, Object c) { ... }
 

See Also:
Borrowed, Immutable

Optional Element Summary
 String value
          When annotating a method, this attribute is used to disambiguate whether the annotation refers to the method's receiver, the method's return value, or both.
 

value

public abstract String value
When annotating a method, this attribute is used to disambiguate whether the annotation refers to the method's receiver, the method's return value, or both. The value is comma separated list of tokens, and has the following set of legal values (ignoring white space issues):

The values are interpreted thusly

This attribute is not used when annotating a parameter or a field: the attribute value must be the empty string in these cases.

The value of this attribute must conform to the following grammar (in Augmented Backus–Naur Form):

 value = [("this" ["," "return"]) / ("return" ["," "this"])] ; See above comments
 

Default:
""


Copyright © 2012 Surelogic, Inc.. All Rights Reserved.