mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
8241100: Make Boolean, Character, Byte, and Short implement Constable
Reviewed-by: jrose, briangoetz, psandoz
This commit is contained in:
parent
2d8bea8c1d
commit
31041d406a
8 changed files with 330 additions and 14 deletions
|
@ -27,6 +27,15 @@ package java.lang;
|
|||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
|
||||
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 Boolean class wraps a value of the primitive type
|
||||
* {@code boolean} in an object. An object of type
|
||||
|
@ -43,7 +52,7 @@ import jdk.internal.HotSpotIntrinsicCandidate;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final class Boolean implements java.io.Serializable,
|
||||
Comparable<Boolean>
|
||||
Comparable<Boolean>, Constable
|
||||
{
|
||||
/**
|
||||
* The {@code Boolean} object corresponding to the primitive
|
||||
|
@ -344,4 +353,16 @@ public final class Boolean implements java.io.Serializable,
|
|||
public static boolean logicalXor(boolean a, boolean b) {
|
||||
return a ^ b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Boolean} instance
|
||||
* @since 15
|
||||
*/
|
||||
@Override
|
||||
public Optional<DynamicConstantDesc<Boolean>> describeConstable() {
|
||||
return Optional.of(value ? ConstantDescs.TRUE : ConstantDescs.FALSE);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue