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
|
@ -25,14 +25,22 @@
|
|||
|
||||
package java.lang;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import java.lang.constant.Constable;
|
||||
import java.lang.constant.DynamicConstantDesc;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import static java.lang.constant.ConstantDescs.BSM_EXPLICIT_CAST;
|
||||
import static java.lang.constant.ConstantDescs.CD_char;
|
||||
import static java.lang.constant.ConstantDescs.CD_int;
|
||||
import static java.lang.constant.ConstantDescs.DEFAULT_NAME;
|
||||
|
||||
/**
|
||||
* The {@code Character} class wraps a value of the primitive
|
||||
* type {@code char} in an object. An object of class
|
||||
|
@ -122,7 +130,7 @@ import jdk.internal.misc.VM;
|
|||
* @since 1.0
|
||||
*/
|
||||
public final
|
||||
class Character implements java.io.Serializable, Comparable<Character> {
|
||||
class Character implements java.io.Serializable, Comparable<Character>, Constable {
|
||||
/**
|
||||
* The minimum radix available for conversion to and from strings.
|
||||
* The constant value of this field is the smallest value permitted
|
||||
|
@ -602,6 +610,17 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
*/
|
||||
public static final int MAX_CODE_POINT = 0X10FFFF;
|
||||
|
||||
/**
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Character} instance
|
||||
* @since 15
|
||||
*/
|
||||
@Override
|
||||
public Optional<DynamicConstantDesc<Character>> describeConstable() {
|
||||
return Optional.of(DynamicConstantDesc.ofNamed(BSM_EXPLICIT_CAST, DEFAULT_NAME, CD_char, (int) value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Instances of this class represent particular subsets of the Unicode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue