APIdia Launch Partner
Top Inners Fields Constructors Methods
sun.invoke.util

public Class ValueConversions

extends Object
Class Inheritance
Imports
java.lang.invoke.MethodHandle, .MethodHandles, .MethodHandles.Lookup, .MethodType, jdk.internal.vm.annotation.Stable

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
ValueConversions.WrapperCache

Thread-safe canonicalized mapping from Wrapper to MethodHandle with unsynchronized reads and synchronized writes.

Field Summary

Modifier and TypeField and Description
private static final ValueConversions.WrapperCache[]
private static final ValueConversions.WrapperCache[]
private static final MethodHandles.Lookup
private static final Integer
private static final Class<?>
private static final ValueConversions.WrapperCache[]
private static final Integer

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static byte
booleanToByte(boolean x)

pack-priv static char
booleanToChar(boolean x)

pack-priv static double
booleanToDouble(boolean x)

pack-priv static float
booleanToFloat(boolean x)

pack-priv static int
booleanToInt(boolean x)

pack-priv static long
booleanToLong(boolean x)

pack-priv static short
booleanToShort(boolean x)

pack-priv static Boolean
boxBoolean(boolean x)

pack-priv static Byte
boxByte(byte x)

pack-priv static Character
boxCharacter(char x)

pack-priv static Double
boxDouble(double x)

public static MethodHandle
pack-priv static Float
boxFloat(float x)

pack-priv static Integer
boxInteger(int x)

pack-priv static Long
boxLong(long x)

pack-priv static Short
boxShort(short x)

private static MethodType
pack-priv static boolean
byteToBoolean(byte x)

pack-priv static char
byteToChar(byte x)

pack-priv static double
byteToDouble(byte x)

pack-priv static float
byteToFloat(byte x)

pack-priv static int
byteToInt(byte x)

pack-priv static long
byteToLong(byte x)

pack-priv static short
byteToShort(byte x)

private static String
pack-priv static boolean
charToBoolean(char x)

pack-priv static byte
charToByte(char x)

pack-priv static double
charToDouble(char x)

pack-priv static float
charToFloat(char x)

pack-priv static int
charToInt(char x)

pack-priv static long
charToLong(char x)

pack-priv static short
charToShort(char x)

public static MethodHandle
public static MethodHandle
convertPrimitive(Class<?> src, Class<?> dst)

pack-priv static boolean
doubleToBoolean(double x)

pack-priv static byte
doubleToByte(double x)

pack-priv static char
doubleToChar(double x)

pack-priv static float
doubleToFloat(double x)

pack-priv static int
doubleToInt(double x)

pack-priv static long
doubleToLong(double x)

pack-priv static short
doubleToShort(double x)

pack-priv static boolean
floatToBoolean(float x)

pack-priv static byte
floatToByte(float x)

pack-priv static char
floatToChar(float x)

pack-priv static double
floatToDouble(float x)

pack-priv static int
floatToInt(float x)

pack-priv static long
floatToLong(float x)

pack-priv static short
floatToShort(float x)

pack-priv static byte
fromBoolean(boolean x)

pack-priv static void
public static MethodHandle
pack-priv static boolean
intToBoolean(int x)

pack-priv static byte
intToByte(int x)

pack-priv static char
intToChar(int x)

pack-priv static double
intToDouble(int x)

pack-priv static float
intToFloat(int x)

pack-priv static long
intToLong(int x)

pack-priv static short
intToShort(int x)

pack-priv static boolean
longToBoolean(long x)

pack-priv static byte
longToByte(long x)

pack-priv static char
longToChar(long x)

pack-priv static double
longToDouble(long x)

pack-priv static float
longToFloat(long x)

pack-priv static int
longToInt(long x)

pack-priv static short
longToShort(long x)

private static InternalError
private static ValueConversions.WrapperCache[]
public static Number
primitiveConversion(Wrapper wrap, Object x, boolean cast)

Produce a Number which represents the given value x according to the primitive type of the given wrapper wrap.

pack-priv static boolean
shortToBoolean(short x)

pack-priv static byte
shortToByte(short x)

pack-priv static char
shortToChar(short x)

pack-priv static double
shortToDouble(short x)

pack-priv static float
shortToFloat(short x)

pack-priv static int
shortToInt(short x)

pack-priv static long
shortToLong(short x)

pack-priv static boolean
toBoolean(byte x)

private static MethodHandle
unbox(Wrapper wrap, int kind)

pack-priv static boolean
pack-priv static boolean
unboxBoolean(Object x, boolean cast)

pack-priv static byte
pack-priv static byte
unboxByte(Object x, boolean cast)

public static MethodHandle
unboxCast(Wrapper type)

Return a casting unboxer for the given primitive type.

pack-priv static char
pack-priv static char
unboxCharacter(Object x, boolean cast)

pack-priv static double
pack-priv static double
unboxDouble(Object x, boolean cast)

public static MethodHandle
unboxExact(Wrapper type)

Return an exact unboxer for the given primitive type.

public static MethodHandle
unboxExact(Wrapper type, boolean throwNPE)

Return an exact unboxer for the given primitive type, with optional null-to-zero conversion.

pack-priv static float
pack-priv static float
unboxFloat(Object x, boolean cast)

pack-priv static int
pack-priv static int
unboxInteger(Object x, boolean cast)

pack-priv static long
pack-priv static long
unboxLong(Object x, boolean cast)

pack-priv static short
pack-priv static short
unboxShort(Object x, boolean cast)

private static MethodType
unboxType(Wrapper wrap, int kind)

public static MethodHandle
unboxWiden(Wrapper type)

Return a widening unboxer for the given primitive type.

public static int
widenSubword(Object x)

The JVM verifier allows boolean, byte, short, or char to widen to int.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOX_CONVERSIONSback to summary
private static final ValueConversions.WrapperCache[] BOX_CONVERSIONS
CONVERT_PRIMITIVE_FUNCTIONSback to summary
private static final ValueConversions.WrapperCache[] CONVERT_PRIMITIVE_FUNCTIONS
IMPL_LOOKUPback to summary
private static final MethodHandles.Lookup IMPL_LOOKUP
ONE_INTback to summary
private static final Integer ONE_INT
THIS_CLASSback to summary
private static final Class<?> THIS_CLASS
UNBOX_CONVERSIONSback to summary
private static final ValueConversions.WrapperCache[] UNBOX_CONVERSIONS
ZERO_INTback to summary
private static final Integer ZERO_INT

Constructor Detail

ValueConversionsback to summary
public ValueConversions()

Method Detail

booleanToByteback to summary
pack-priv static byte booleanToByte(boolean x)
booleanToCharback to summary
pack-priv static char booleanToChar(boolean x)
booleanToDoubleback to summary
pack-priv static double booleanToDouble(boolean x)
booleanToFloatback to summary
pack-priv static float booleanToFloat(boolean x)
booleanToIntback to summary
pack-priv static int booleanToInt(boolean x)
booleanToLongback to summary
pack-priv static long booleanToLong(boolean x)
booleanToShortback to summary
pack-priv static short booleanToShort(boolean x)
boxBooleanback to summary
pack-priv static Boolean boxBoolean(boolean x)
boxByteback to summary
pack-priv static Byte boxByte(byte x)
boxCharacterback to summary
pack-priv static Character boxCharacter(char x)
boxDoubleback to summary
pack-priv static Double boxDouble(double x)
boxExactback to summary
public static MethodHandle boxExact(Wrapper wrap)
boxFloatback to summary
pack-priv static Float boxFloat(float x)
boxIntegerback to summary
pack-priv static Integer boxInteger(int x)
boxLongback to summary
pack-priv static Long boxLong(long x)
boxShortback to summary
pack-priv static Short boxShort(short x)
boxTypeback to summary
private static MethodType boxType(Wrapper wrap)
byteToBooleanback to summary
pack-priv static boolean byteToBoolean(byte x)
byteToCharback to summary
pack-priv static char byteToChar(byte x)
byteToDoubleback to summary
pack-priv static double byteToDouble(byte x)
byteToFloatback to summary
pack-priv static float byteToFloat(byte x)
byteToIntback to summary
pack-priv static int byteToInt(byte x)
byteToLongback to summary
pack-priv static long byteToLong(byte x)
byteToShortback to summary
pack-priv static short byteToShort(byte x)
capitalizeback to summary
private static String capitalize(String x)
charToBooleanback to summary
pack-priv static boolean charToBoolean(char x)
charToByteback to summary
pack-priv static byte charToByte(char x)
charToDoubleback to summary
pack-priv static double charToDouble(char x)
charToFloatback to summary
pack-priv static float charToFloat(char x)
charToIntback to summary
pack-priv static int charToInt(char x)
charToLongback to summary
pack-priv static long charToLong(char x)
charToShortback to summary
pack-priv static short charToShort(char x)
convertPrimitiveback to summary
public static MethodHandle convertPrimitive(Wrapper wsrc, Wrapper wdst)
convertPrimitiveback to summary
public static MethodHandle convertPrimitive(Class<?> src, Class<?> dst)
doubleToBooleanback to summary
pack-priv static boolean doubleToBoolean(double x)
doubleToByteback to summary
pack-priv static byte doubleToByte(double x)
doubleToCharback to summary
pack-priv static char doubleToChar(double x)
doubleToFloatback to summary
pack-priv static float doubleToFloat(double x)
doubleToIntback to summary
pack-priv static int doubleToInt(double x)
doubleToLongback to summary
pack-priv static long doubleToLong(double x)
doubleToShortback to summary
pack-priv static short doubleToShort(double x)
floatToBooleanback to summary
pack-priv static boolean floatToBoolean(float x)
floatToByteback to summary
pack-priv static byte floatToByte(float x)
floatToCharback to summary
pack-priv static char floatToChar(float x)
floatToDoubleback to summary
pack-priv static double floatToDouble(float x)
floatToIntback to summary
pack-priv static int floatToInt(float x)
floatToLongback to summary
pack-priv static long floatToLong(float x)
floatToShortback to summary
pack-priv static short floatToShort(float x)
fromBooleanback to summary
pack-priv static byte fromBoolean(boolean x)
ignoreback to summary
pack-priv static void ignore(Object x)
ignoreback to summary
public static MethodHandle ignore()
intToBooleanback to summary
pack-priv static boolean intToBoolean(int x)
intToByteback to summary
pack-priv static byte intToByte(int x)
intToCharback to summary
pack-priv static char intToChar(int x)
intToDoubleback to summary
pack-priv static double intToDouble(int x)
intToFloatback to summary
pack-priv static float intToFloat(int x)
intToLongback to summary
pack-priv static long intToLong(int x)
intToShortback to summary
pack-priv static short intToShort(int x)
longToBooleanback to summary
pack-priv static boolean longToBoolean(long x)
longToByteback to summary
pack-priv static byte longToByte(long x)
longToCharback to summary
pack-priv static char longToChar(long x)
longToDoubleback to summary
pack-priv static double longToDouble(long x)
longToFloatback to summary
pack-priv static float longToFloat(long x)
longToIntback to summary
pack-priv static int longToInt(long x)
longToShortback to summary
pack-priv static short longToShort(long x)
newInternalErrorback to summary
private static InternalError newInternalError(String message, Throwable cause)
newWrapperCachesback to summary
private static ValueConversions.WrapperCache[] newWrapperCaches(int n)
primitiveConversionback to summary
public static Number primitiveConversion(Wrapper wrap, Object x, boolean cast)

Produce a Number which represents the given value x according to the primitive type of the given wrapper wrap. Caller must invoke intValue, byteValue, longValue (etc.) on the result to retrieve the desired primitive value.

shortToBooleanback to summary
pack-priv static boolean shortToBoolean(short x)
shortToByteback to summary
pack-priv static byte shortToByte(short x)
shortToCharback to summary
pack-priv static char shortToChar(short x)
shortToDoubleback to summary
pack-priv static double shortToDouble(short x)
shortToFloatback to summary
pack-priv static float shortToFloat(short x)
shortToIntback to summary
pack-priv static int shortToInt(short x)
shortToLongback to summary
pack-priv static long shortToLong(short x)
toBooleanback to summary
pack-priv static boolean toBoolean(byte x)
unboxback to summary
private static MethodHandle unbox(Wrapper wrap, int kind)
unboxBooleanback to summary
pack-priv static boolean unboxBoolean(Boolean x)
unboxBooleanback to summary
pack-priv static boolean unboxBoolean(Object x, boolean cast)
unboxByteback to summary
pack-priv static byte unboxByte(Byte x)
unboxByteback to summary
pack-priv static byte unboxByte(Object x, boolean cast)
unboxCastback to summary
public static MethodHandle unboxCast(Wrapper type)

Return a casting unboxer for the given primitive type. Widen or narrow primitive values to the given type, or convert null to zero, as needed. The type of the unboxer is of a form like (Object)int.

unboxCharacterback to summary
pack-priv static char unboxCharacter(Character x)
unboxCharacterback to summary
pack-priv static char unboxCharacter(Object x, boolean cast)
unboxDoubleback to summary
pack-priv static double unboxDouble(Double x)
unboxDoubleback to summary
pack-priv static double unboxDouble(Object x, boolean cast)
unboxExactback to summary
public static MethodHandle unboxExact(Wrapper type)

Return an exact unboxer for the given primitive type.

unboxExactback to summary
public static MethodHandle unboxExact(Wrapper type, boolean throwNPE)

Return an exact unboxer for the given primitive type, with optional null-to-zero conversion. The boolean says whether to throw an NPE on a null value (false means unbox a zero). The type of the unboxer is of a form like (Integer)int.

unboxFloatback to summary
pack-priv static float unboxFloat(Float x)
unboxFloatback to summary
pack-priv static float unboxFloat(Object x, boolean cast)
unboxIntegerback to summary
pack-priv static int unboxInteger(Integer x)
unboxIntegerback to summary
pack-priv static int unboxInteger(Object x, boolean cast)
unboxLongback to summary
pack-priv static long unboxLong(Long x)
unboxLongback to summary
pack-priv static long unboxLong(Object x, boolean cast)
unboxShortback to summary
pack-priv static short unboxShort(Short x)
unboxShortback to summary
pack-priv static short unboxShort(Object x, boolean cast)
unboxTypeback to summary
private static MethodType unboxType(Wrapper wrap, int kind)
unboxWidenback to summary
public static MethodHandle unboxWiden(Wrapper type)

Return a widening unboxer for the given primitive type. Widen narrower primitive boxes to the given type. Do not narrow any primitive values or convert null to zero. The type of the unboxer is of a form like (Object)int.

widenSubwordback to summary
public static int widenSubword(Object x)

The JVM verifier allows boolean, byte, short, or char to widen to int. Support exactly this conversion, from a boxed value type Boolean, Byte, Short, Character, or Integer.

sun.invoke.util back to summary

private Class ValueConversions.Handles

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final MethodHandle

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

IGNOREback to summary
pack-priv static final MethodHandle IGNORE

Constructor Detail

Handlesback to summary
private Handles()
sun.invoke.util back to summary

private Class ValueConversions.WrapperCache

extends Object
Class Inheritance

Thread-safe canonicalized mapping from Wrapper to MethodHandle with unsynchronized reads and synchronized writes. It's safe to publish MethodHandles by data race because they are immutable.

Field Summary

Modifier and TypeField and Description
private final MethodHandle[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public MethodHandle
public synchronized MethodHandle
put(final Wrapper w, final MethodHandle mh)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mapback to summary
private final MethodHandle[] map
Annotations
@Stable

Constructor Detail

WrapperCacheback to summary
private WrapperCache()

Method Detail

getback to summary
public MethodHandle get(Wrapper w)
putback to summary
public synchronized MethodHandle put(final Wrapper w, final MethodHandle mh)