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

public final Enum Wrapper

extends Enum<Wrapper>
Class Inheritance
Static Imports
sun.invoke.util.Wrapper.NumericClasses.*

Nested and Inner Type Summary

Modifier and TypeClass and Description
private abstract static class
public static class

Field Summary

Modifier and TypeField and Description
private final ClassDesc
private final char
private final String
public static final Wrapper
public static final Wrapper
public static final Wrapper
public static final int
public static final Wrapper
private static final Object
private final Object
public static final Wrapper
private static final Object
private final int
private static final Wrapper[]
public static final Wrapper
public static final Wrapper
private final int
public static final Wrapper
private final String
private final Class<?>
public static final Wrapper
private final int
public static final Wrapper
private final ClassDesc
private final String
private final Class<?>

Constructor Summary

AccessConstructor and Description
private
Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format, int numericClass, int superClasses, ClassDesc basicClassDesc, ClassDesc wrapperClassDesc)

Method Summary

Modifier and TypeMethod and Description
public Class<?>
public static <T> Class<T>
asPrimitiveType(Class<T> type)

If type is a wrapper type, return the corresponding primitive type, else return type unchanged.

public static <T> Class<T>
asWrapperType(Class<T> type)

If type is a primitive type, return the corresponding wrapper type, else return type unchanged.

public ClassDesc
basicClassDescriptor()

A nominal descriptor of the wrapped type

public static char
basicTypeChar(Class<?> type)

What is the bytecode signature character for this type?

public char
basicTypeChar()

What is the bytecode signature character for this wrapper's primitive type?

private static RuntimeException
basicTypeError(char type)

public String
basicTypeString()

What is the bytecode signature string for this wrapper's primitive type?

public int
bitWidth()

How many bits are in the wrapped value?

private static boolean
boolValue(byte bits)

public <T> T
cast(Object x, Class<T> type)

Cast a wrapped value to the given type, which may be either a primitive or wrapper type.

private static boolean
public <T> T
convert(Object x, Class<T> type)

Convert a wrapped value to the given type.

private <T> T
convert(Object x, Class<T> type, boolean isCast)

public void
copyArrayBoxing(Object a, int apos, Object[] values, int vpos, int length)

public void
copyArrayUnboxing(Object[] values, int vpos, Object a, int apos, int length)

public String
detailString()

For debugging, give the details of this wrapper.

pack-priv static Wrapper
public static Wrapper
forBasicType(char type)

Return the wrapper that corresponds to the given bytecode signature character.

public static Wrapper
forBasicType(Class<?> type)

Return the wrapper for the given type, if it is a primitive type, else return OBJECT.

pack-priv static <T> Class<T>
forceType(Class<?> type, Class<T> exampleType)

Cast a reference type to another reference type.

public static Wrapper
forPrimitiveType(Class<?> type)

Return the wrapper that wraps values of the given type.

public static Wrapper
forWrapperType(Class<?> type)

Return the wrapper that wraps values into the given wrapper type.

public boolean
isConvertibleFrom(Wrapper source)

Does the JLS 5.1.2 allow a variable of this wrapper's primitive type to be assigned from a value of the given wrapper's primitive type?

public boolean
isDoubleWord()

Does the wrapped value occupy two JVM stack slots?

public boolean
isFloating()

Is the wrapped type either float or double?

public boolean
isIntegral()

Is the wrapped type a primitive other than float, double, or void?

public boolean
isNumeric()

Is the wrapped type numeric (not void or object)?

public boolean
isOther()

Is the wrapped type either void or a reference?

public static boolean
isPrimitiveType(Class<?> type)

Query: Is the given type a primitive, such as int or void?

public boolean
public boolean
isSingleWord()

Does the wrapped value occupy a single JVM stack slot?

public boolean
public boolean
isSubwordOrInt()

Is the wrapped type one of int, boolean, byte, char, or short?

public boolean
public static boolean
isWrapperNumericOrBooleanType(Class<?> type)

Query: Is the given type a wrapper, such as Integer, Byte, etc excluding Void and Object?

public static boolean
isWrapperType(Class<?> type)

Query: Is the given type a wrapper, such as Integer or Void?

public Object
makeArray(int len)

private static ClassCastException
newClassCastException(Class<?> actual, Class<?> expected)

private static RuntimeException
private static RuntimeException
private static Number
public String
primitiveSimpleName()

What is the simple name of the primitive type?

public Class<?>
primitiveType()

What is the primitive type wrapped by this wrapper?

public int
stackSlots()

How many JVM stack slots occupied by the wrapped value?

public static Wrapper
public static Wrapper[]
public Object
wrap(Object x)

Wrap a value in this wrapper's type.

public Object
wrap(int x)

Wrap a value (an int or smaller value) in this wrapper's type.

public ClassDesc
wrapperClassDescriptor()

A nominal descriptor of the wrapper type

public String
wrapperSimpleName()

What is the simple name of the wrapper type?

public Class<?>
wrapperType()

What is the wrapper type for this wrapper?

public <T> Class<T>
wrapperType(Class<T> exampleType)

What is the wrapper type for this wrapper?

private static RuntimeException
public Object
zero()

Produce a zero value for the given wrapper type.

public <T> T
zero(Class<T> type)

Produce a zero value for the given wrapper type T.

Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

basicClassDescback to summary
private final ClassDesc basicClassDesc
basicTypeCharback to summary
private final char basicTypeChar
basicTypeStringback to summary
private final String basicTypeString
BOOLEANback to summary
public static final Wrapper BOOLEAN
BYTEback to summary
public static final Wrapper BYTE
CHARback to summary
public static final Wrapper CHAR
COUNTback to summary
public static final int COUNT
DOUBLEback to summary
public static final Wrapper DOUBLE
DOUBLE_ZEROback to summary
private static final Object DOUBLE_ZERO
emptyArrayback to summary
private final Object emptyArray
FLOATback to summary
public static final Wrapper FLOAT
FLOAT_ZEROback to summary
private static final Object FLOAT_ZERO
formatback to summary
private final int format
FROM_CHARback to summary
private static final Wrapper[] FROM_CHAR
INTback to summary
public static final Wrapper INT
LONGback to summary
public static final Wrapper LONG
numericClassback to summary
private final int numericClass
OBJECTback to summary
public static final Wrapper OBJECT
primitiveSimpleNameback to summary
private final String primitiveSimpleName
primitiveTypeback to summary
private final Class<?> primitiveType
SHORTback to summary
public static final Wrapper SHORT
superClassesback to summary
private final int superClasses
VOIDback to summary
public static final Wrapper VOID
wrapperClassDescback to summary
private final ClassDesc wrapperClassDesc
wrapperSimpleNameback to summary
private final String wrapperSimpleName
wrapperTypeback to summary
private final Class<?> wrapperType

Constructor Detail

Wrapperback to summary
private Wrapper(Class<?> wtype, String wtypeName, Class<?> ptype, String ptypeName, char tchar, Object emptyArray, int format, int numericClass, int superClasses, ClassDesc basicClassDesc, ClassDesc wrapperClassDesc)

Method Detail

arrayTypeback to summary
public Class<?> arrayType()
asPrimitiveTypeback to summary
public static <T> Class<T> asPrimitiveType(Class<T> type)

If type is a wrapper type, return the corresponding primitive type, else return type unchanged.

asWrapperTypeback to summary
public static <T> Class<T> asWrapperType(Class<T> type)

If type is a primitive type, return the corresponding wrapper type, else return type unchanged.

basicClassDescriptorback to summary
public ClassDesc basicClassDescriptor()

A nominal descriptor of the wrapped type

basicTypeCharback to summary
public static char basicTypeChar(Class<?> type)

What is the bytecode signature character for this type? All non-primitives, including array types, report as 'L', the signature character for references.

basicTypeCharback to summary
public char basicTypeChar()

What is the bytecode signature character for this wrapper's primitive type?

basicTypeErrorback to summary
private static RuntimeException basicTypeError(char type)
Annotations
@DontInline
basicTypeStringback to summary
public String basicTypeString()

What is the bytecode signature string for this wrapper's primitive type?

bitWidthback to summary
public int bitWidth()

How many bits are in the wrapped value? Returns 0 for OBJECT or VOID.

boolValueback to summary
private static boolean boolValue(byte bits)
castback to summary
public <T> T cast(Object x, Class<T> type)

Cast a wrapped value to the given type, which may be either a primitive or wrapper type. The given target type must be this wrapper's primitive or wrapper type. If this wrapper is OBJECT, the target type may also be an interface, perform no runtime check. Performs standard primitive conversions, including truncation and float conversions. The given type must be compatible with this wrapper. That is, it must either be the wrapper type (or a subtype, in the case of OBJECT) or else it must be the wrapper's primitive type. Primitive conversions are only performed if the given type is itself a primitive.

Exceptions
ClassCastException:
if the given type is not compatible with this wrapper
checkConvertibleFromback to summary
private static boolean checkConvertibleFrom()
convertback to summary
public <T> T convert(Object x, Class<T> type)

Convert a wrapped value to the given type. The given target type must be this wrapper's primitive or wrapper type. This is equivalent to cast, except that it refuses to perform narrowing primitive conversions.

convertback to summary
private <T> T convert(Object x, Class<T> type, boolean isCast)
copyArrayBoxingback to summary
public void copyArrayBoxing(Object a, int apos, Object[] values, int vpos, int length)
copyArrayUnboxingback to summary
public void copyArrayUnboxing(Object[] values, int vpos, Object a, int apos, int length)
detailStringback to summary
public String detailString()

For debugging, give the details of this wrapper.

findWrapperTypeback to summary
pack-priv static Wrapper findWrapperType(Class<?> type)
forBasicTypeback to summary
public static Wrapper forBasicType(char type)

Return the wrapper that corresponds to the given bytecode signature character. Return OBJECT for the character 'L'.

Exceptions
IllegalArgumentException:
for any non-signature character or '['.
forBasicTypeback to summary
public static Wrapper forBasicType(Class<?> type)

Return the wrapper for the given type, if it is a primitive type, else return OBJECT.

forceTypeback to summary
pack-priv static <T> Class<T> forceType(Class<?> type, Class<T> exampleType)

Cast a reference type to another reference type. If the target type is an interface, perform no runtime check. (This loophole is safe, and is allowed by the JVM verifier.) If the target type is a primitive, change it to a wrapper.

forPrimitiveTypeback to summary
public static Wrapper forPrimitiveType(Class<?> type)

Return the wrapper that wraps values of the given type. The type may be Object, meaning the OBJECT wrapper. Otherwise, the type must be a primitive.

Exceptions
IllegalArgumentException:
for unexpected types
forWrapperTypeback to summary
public static Wrapper forWrapperType(Class<?> type)

Return the wrapper that wraps values into the given wrapper type. If it is Object, return OBJECT. Otherwise, it must be a wrapper type. The type must not be a primitive type.

Exceptions
IllegalArgumentException:
for unexpected types
isConvertibleFromback to summary
public boolean isConvertibleFrom(Wrapper source)

Does the JLS 5.1.2 allow a variable of this wrapper's primitive type to be assigned from a value of the given wrapper's primitive type? Cases:

  • unboxing followed by widening primitive conversion
  • any type converted to void (i.e., dropping a method call's value)
  • boxing conversion followed by widening reference conversion to Object
These are the cases allowed by MethodHandle.asType.
isDoubleWordback to summary
public boolean isDoubleWord()

Does the wrapped value occupy two JVM stack slots?

isFloatingback to summary
public boolean isFloating()

Is the wrapped type either float or double?

isIntegralback to summary
public boolean isIntegral()

Is the wrapped type a primitive other than float, double, or void?

isNumericback to summary
public boolean isNumeric()

Is the wrapped type numeric (not void or object)?

isOtherback to summary
public boolean isOther()

Is the wrapped type either void or a reference?

isPrimitiveTypeback to summary
public static boolean isPrimitiveType(Class<?> type)

Query: Is the given type a primitive, such as int or void?

isSignedback to summary
public boolean isSigned()
isSingleWordback to summary
public boolean isSingleWord()

Does the wrapped value occupy a single JVM stack slot?

isStrictSubRangeOfback to summary
public boolean isStrictSubRangeOf(Wrapper target)
isSubwordOrIntback to summary
public boolean isSubwordOrInt()

Is the wrapped type one of int, boolean, byte, char, or short?

isUnsignedback to summary
public boolean isUnsigned()
isWrapperNumericOrBooleanTypeback to summary
public static boolean isWrapperNumericOrBooleanType(Class<?> type)

Query: Is the given type a wrapper, such as Integer, Byte, etc excluding Void and Object?

isWrapperTypeback to summary
public static boolean isWrapperType(Class<?> type)

Query: Is the given type a wrapper, such as Integer or Void?

makeArrayback to summary
public Object makeArray(int len)
newClassCastExceptionback to summary
private static ClassCastException newClassCastException(Class<?> actual, Class<?> expected)
newIllegalArgumentExceptionback to summary
private static RuntimeException newIllegalArgumentException(String message, Object x)
newIllegalArgumentExceptionback to summary
private static RuntimeException newIllegalArgumentException(String message)
numberValueback to summary
private static Number numberValue(Object x)
primitiveSimpleNameback to summary
public String primitiveSimpleName()

What is the simple name of the primitive type?

primitiveTypeback to summary
public Class<?> primitiveType()

What is the primitive type wrapped by this wrapper?

stackSlotsback to summary
public int stackSlots()

How many JVM stack slots occupied by the wrapped value? Returns 0 for VOID.

valueOfback to summary
public static Wrapper valueOf(String name)
valuesback to summary
public static Wrapper[] values()
wrapback to summary
public Object wrap(Object x)

Wrap a value in this wrapper's type. Performs standard primitive conversions, including truncation and float conversions. Performs returns the unchanged reference for OBJECT. Returns null for VOID. Returns a zero value for a null input.

Exceptions
ClassCastException:
if this wrapper is numeric and the operand is not a number, character, boolean, or null
wrapback to summary
public Object wrap(int x)

Wrap a value (an int or smaller value) in this wrapper's type. Performs standard primitive conversions, including truncation and float conversions. Produces an Integer for OBJECT, although the exact type of the operand is not known. Returns null for VOID.

wrapperClassDescriptorback to summary
public ClassDesc wrapperClassDescriptor()

A nominal descriptor of the wrapper type

wrapperSimpleNameback to summary
public String wrapperSimpleName()

What is the simple name of the wrapper type?

wrapperTypeback to summary
public Class<?> wrapperType()

What is the wrapper type for this wrapper?

wrapperTypeback to summary
public <T> Class<T> wrapperType(Class<T> exampleType)

What is the wrapper type for this wrapper? Otherwise, the example type must be the wrapper type, or the corresponding primitive type. (For OBJECT, the example type can be any non-primitive, and is normalized to Object.class.) The resulting class type has the same type parameter.

wrapperTypeErrorback to summary
private static RuntimeException wrapperTypeError(Class<?> type)
Annotations
@DontInline
zeroback to summary
public Object zero()

Produce a zero value for the given wrapper type. This will be a numeric zero for a number or character, false for a boolean, and null for a reference or void. The common thread is that this is what is contained in a default-initialized variable of the given primitive type. (For void, it is what a reflective method returns instead of no value at all.)

zeroback to summary
public <T> T zero(Class<T> type)

Produce a zero value for the given wrapper type T. The optional argument must a type compatible with this wrapper. Equivalent to this.cast(this.zero(), type).

sun.invoke.util back to summary

private abstract Class Wrapper.Format

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static int
floating(int size)

pack-priv static int
format(int kind, int size, int slots)

pack-priv static int
other(int slots)

pack-priv static int
signed(int size)

pack-priv static int
unsigned(int size)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BOOLEANback to summary
pack-priv static final int BOOLEAN
CHARback to summary
pack-priv static final int CHAR
FLOATback to summary
pack-priv static final int FLOAT
FLOATINGback to summary
pack-priv static final int FLOATING
INTback to summary
pack-priv static final int INT
KIND_SHIFTback to summary
pack-priv static final int KIND_SHIFT
NUM_MASKback to summary
pack-priv static final int NUM_MASK
SHORTback to summary
pack-priv static final int SHORT
SIGNEDback to summary
pack-priv static final int SIGNED
SIZE_MASKback to summary
pack-priv static final int SIZE_MASK
SIZE_SHIFTback to summary
pack-priv static final int SIZE_SHIFT
SLOT_MASKback to summary
pack-priv static final int SLOT_MASK
SLOT_SHIFTback to summary
pack-priv static final int SLOT_SHIFT
UNSIGNEDback to summary
pack-priv static final int UNSIGNED
VOIDback to summary
pack-priv static final int VOID

Constructor Detail

Formatback to summary
private Format()

Method Detail

floatingback to summary
pack-priv static int floating(int size)
formatback to summary
pack-priv static int format(int kind, int size, int slots)
otherback to summary
pack-priv static int other(int slots)
signedback to summary
pack-priv static int signed(int size)
unsignedback to summary
pack-priv static int unsigned(int size)
sun.invoke.util back to summary

public Class Wrapper.NumericClasses

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final int
pack-priv static final int
public static final int
pack-priv static final int
public static final int
public static final int
pack-priv static final int
public static final int
pack-priv static final int
public static final int
pack-priv static final int
public static final int
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

BYTE_CLASSback to summary
public static final int BYTE_CLASS
BYTE_SUPERCLASSESback to summary
pack-priv static final int BYTE_SUPERCLASSES
CHAR_CLASSback to summary
public static final int CHAR_CLASS
CHAR_SUPERCLASSESback to summary
pack-priv static final int CHAR_SUPERCLASSES
DOUBLE_CLASSback to summary
public static final int DOUBLE_CLASS
FLOAT_CLASSback to summary
public static final int FLOAT_CLASS
FLOAT_SUPERCLASSESback to summary
pack-priv static final int FLOAT_SUPERCLASSES
INT_CLASSback to summary
public static final int INT_CLASS
INT_SUPERCLASSESback to summary
pack-priv static final int INT_SUPERCLASSES
LONG_CLASSback to summary
public static final int LONG_CLASS
LONG_SUPERCLASSESback to summary
pack-priv static final int LONG_SUPERCLASSES
SHORT_CLASSback to summary
public static final int SHORT_CLASS
SHORT_SUPERCLASSESback to summary
pack-priv static final int SHORT_SUPERCLASSES

Constructor Detail

NumericClassesback to summary
public NumericClasses()