KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > jcip > annotations > Immutable


1 package net.jcip.annotations;
2 import java.lang.annotation.*;
3
4 /*
5  * Copyright (c) 2005 Brian Goetz
6  * Released under the Creative Commons Attribution License
7  * (http://creativecommons.org/licenses/by/2.5)
8  * Official home: http://www.jcip.net
9  */

10
11 /**
12  * Immutable
13  *
14  * The class to which this annotation is applied is immutable. This means that
15  * its state cannot be seen to change by callers. Of necessity this means that
16  * all public fields are final, and that all public final reference fields refer
17  * to other immutable objects, and that methods do not publish references to any
18  * internal state which is mutable by implementation even if not by design.
19  * Immutable objects may still have internal mutable state for purposes of performance
20  * optimization; some state variables may be lazily computed, so long as they are computed
21  * from immutable state and that callers cannot tell the difference.
22  *
23  * Immutable objects are inherently thread-safe; they may be passed between threads or
24  * published without synchronization.
25  */

26 @Documented
27 @Target(ElementType.TYPE)
28 @Retention(RetentionPolicy.CLASS)
29 public @interface Immutable {
30 }
31
Popular Tags