< prev index next > src/java.base/share/classes/java/lang/Boolean.java
Print this page
* questions.
*/
package java.lang;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import java.lang.constant.Constable;
- import java.lang.constant.ConstantDesc;
import java.lang.constant.ConstantDescs;
import java.lang.constant.DynamicConstantDesc;
import java.util.Optional;
- import static java.lang.constant.ConstantDescs.BSM_GET_STATIC_FINAL;
- import static java.lang.constant.ConstantDescs.CD_Boolean;
-
/**
* The {@code Boolean} class is the {@linkplain
* java.lang##wrapperClass wrapper class} for values of the primitive
* type {@code boolean}. An object of type {@code Boolean} contains a
* single field whose type is {@code boolean}.
* questions.
*/
package java.lang;
+ import jdk.internal.value.DeserializeConstructor;
import jdk.internal.vm.annotation.IntrinsicCandidate;
import java.lang.constant.Constable;
import java.lang.constant.ConstantDescs;
import java.lang.constant.DynamicConstantDesc;
import java.util.Optional;
/**
* The {@code Boolean} class is the {@linkplain
* java.lang##wrapperClass wrapper class} for values of the primitive
* type {@code boolean}. An object of type {@code Boolean} contains a
* single field whose type is {@code boolean}.
* {@code String} to a {@code boolean}, as well as other
* constants and methods useful when dealing with a
* {@code boolean}.
*
* <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
! * class; programmers should treat instances that are
! * {@linkplain #equals(Object) equal} as interchangeable and should not
! * use instances for synchronization, or unpredictable behavior may
! * occur. For example, in a future release, synchronization may fail.
*
* @author Arthur van Hoff
* @since 1.0
*/
@jdk.internal.ValueBased
public final class Boolean implements java.io.Serializable,
Comparable<Boolean>, Constable
{
/**
* {@code String} to a {@code boolean}, as well as other
* constants and methods useful when dealing with a
* {@code boolean}.
*
* <p>This is a <a href="{@docRoot}/java.base/java/lang/doc-files/ValueBased.html">value-based</a>
! * class; programmers should treat instances that are {@linkplain #equals(Object) equal}
! * as interchangeable and should not use instances for synchronization, mutexes, or
! * with {@linkplain java.lang.ref.Reference object references}.
! *
+ * <div class="preview-block">
+ * <div class="preview-comment">
+ * When preview features are enabled, {@code Boolean} is a {@linkplain Class#isValue value class}.
+ * Use of value class instances for synchronization, mutexes, or with
+ * {@linkplain java.lang.ref.Reference object references} result in
+ * {@link IdentityException}.
+ * </div>
+ * </div>
*
* @author Arthur van Hoff
* @since 1.0
*/
+ @jdk.internal.MigratedValueClass
@jdk.internal.ValueBased
public final class Boolean implements java.io.Serializable,
Comparable<Boolean>, Constable
{
/**
* @param b a boolean value.
* @return a {@code Boolean} instance representing {@code b}.
* @since 1.4
*/
@IntrinsicCandidate
+ @DeserializeConstructor
public static Boolean valueOf(boolean b) {
return (b ? TRUE : FALSE);
}
/**
< prev index next >