01: package net.jcip.annotations;
02:
03: import java.lang.annotation.*;
04:
05: /*
06: * Copyright (c) 2005 Brian Goetz and Tim Peierls
07: * Released under the Creative Commons Attribution License
08: * (http://creativecommons.org/licenses/by/2.5)
09: * Official home: http://www.jcip.net
10: *
11: * Any republication or derived work distributed in source code form
12: * must include this copyright and license notice.
13: */
14:
15: /**
16: * The class to which this annotation is applied is immutable. This means that
17: * its state cannot be seen to change by callers, which implies that
18: * <ul>
19: * <li> all public fields are final, </li>
20: * <li> all public final reference fields refer to other immutable objects, and </li>
21: * <li> constructors and methods do not publish references to any internal state
22: * which is potentially mutable by the implementation. </li>
23: * </ul>
24: * Immutable objects may still have internal mutable state for purposes of performance
25: * optimization; some state variables may be lazily computed, so long as they are computed
26: * from immutable state and that callers cannot tell the difference.
27: * <p>
28: * Immutable objects are inherently thread-safe; they may be passed between threads or
29: * published without synchronization.
30: */
31: @Documented
32: @Target(ElementType.TYPE)
33: @Retention(RetentionPolicy.RUNTIME)
34: public @interface Immutable {
35: }
|