44 *
45 * <p>In addition, this class provides many methods for
46 * converting a {@code boolean} to a {@code String} and a
47 * {@code String} to a {@code boolean}, as well as other
48 * constants and methods useful when dealing with a
49 * {@code boolean}.
50 *
51 * <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
52 * class; programmers should treat instances that are
53 * {@linkplain #equals(Object) equal} as interchangeable and should not
54 * use instances for synchronization, or unpredictable behavior may
55 * occur. For example, in a future release, synchronization may fail.
56 *
57 * @author Arthur van Hoff
58 * @since 1.0
59 */
60 @jdk.internal.ValueBased
61 public final class Boolean implements java.io.Serializable,
62 Comparable<Boolean>, Constable
63 {
64 /**
65 * The {@code Boolean} object corresponding to the primitive
66 * value {@code true}.
67 */
68 public static final Boolean TRUE = new Boolean(true);
69
70 /**
71 * The {@code Boolean} object corresponding to the primitive
72 * value {@code false}.
73 */
74 public static final Boolean FALSE = new Boolean(false);
75
76 /**
77 * The Class object representing the primitive type boolean.
78 *
79 * @since 1.1
80 */
81 @SuppressWarnings("unchecked")
82 public static final Class<Boolean> TYPE = (Class<Boolean>) Class.getPrimitiveClass("boolean");
83
84 /**
85 * The value of the Boolean.
86 *
87 * @serial
88 */
89 private final boolean value;
90
91 /** use serialVersionUID from JDK 1.0.2 for interoperability */
92 @java.io.Serial
93 private static final long serialVersionUID = -3665804199014368530L;
94
|
44 *
45 * <p>In addition, this class provides many methods for
46 * converting a {@code boolean} to a {@code String} and a
47 * {@code String} to a {@code boolean}, as well as other
48 * constants and methods useful when dealing with a
49 * {@code boolean}.
50 *
51 * <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
52 * class; programmers should treat instances that are
53 * {@linkplain #equals(Object) equal} as interchangeable and should not
54 * use instances for synchronization, or unpredictable behavior may
55 * occur. For example, in a future release, synchronization may fail.
56 *
57 * @author Arthur van Hoff
58 * @since 1.0
59 */
60 @jdk.internal.ValueBased
61 public final class Boolean implements java.io.Serializable,
62 Comparable<Boolean>, Constable
63 {
64 // AOT cache support - there are references to these fields by other cached Java objects. We need
65 // to preserve their identity across AOT cache assembly phase and production runs.
66 static class AOTHolder {
67 private static final Boolean TRUE = new Boolean(true);
68 private static final Boolean FALSE = new Boolean(false);
69 }
70
71 /**
72 * The {@code Boolean} object corresponding to the primitive
73 * value {@code true}.
74 */
75 public static final Boolean TRUE = AOTHolder.TRUE;
76
77 /**
78 * The {@code Boolean} object corresponding to the primitive
79 * value {@code false}.
80 */
81 public static final Boolean FALSE = AOTHolder.FALSE;
82
83 /**
84 * The Class object representing the primitive type boolean.
85 *
86 * @since 1.1
87 */
88 @SuppressWarnings("unchecked")
89 public static final Class<Boolean> TYPE = (Class<Boolean>) Class.getPrimitiveClass("boolean");
90
91 /**
92 * The value of the Boolean.
93 *
94 * @serial
95 */
96 private final boolean value;
97
98 /** use serialVersionUID from JDK 1.0.2 for interoperability */
99 @java.io.Serial
100 private static final long serialVersionUID = -3665804199014368530L;
101
|