@Documented @Retention(value=RUNTIME) @Target(value=TYPE) public @interface Mutable
This annotation is not verified, it is intended for documentation of programmer intent only.
A type may not be annotated with both @Immutable and
@Mutable.
@ThreadSafeThread safety and immutability are two points along the same axis. This set of annotations can actually describe three points along the axis:
@Mutable and @NotThreadSafe
@Mutable
, or just @NotThreadSafe. The type contains mutable state
that is not safe to access concurrently from multiple threads.
@Mutable and @ThreadSafe
@ThreadSafe. The type contains
mutable state that is safe to access concurrently from multiple threads.
@Immutable and @ThreadSafe
@Immutable. The type contains no
mutable state, and is thus safe to access concurrently from multiple threads.
The combination @Immutable and
@NotThreadSafe is a modeling error because an immutable
type is obviously thread safe.
@Mutable
public class Aircraft {
private final Lock stateLock = new ReentrantLock();
...
@GuardedBy("stateLock")
private long x, y;
...
public void setPosition(long x, long y) {
stateLock.lock();
try {
this.x = x;
this.y = y;
} finally {
stateLock.unlock();
}
}
...
}
@annotate tag.
/**
* @annotate Mutable
*/
public class Aircraft {
...
}
ImmutableCopyright © 2012 Surelogic, Inc.. All Rights Reserved.