LinkerServices#asType(MethodHandle, MethodType). It manages the known GuardingTypeConverterFactory
instances and creates appropriate converters for method handles.
| Modifier and Type | Class and Description |
|---|---|
| private static class | |
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final MethodTypeConversionStrategy | |
| private final BiClassValue | |
| private final ConversionComparator[] | |
| private final BiClassValue | |
| private final BiClassValue | |
| pack-priv static final MethodHandle |
| Access | Constructor and Description |
|---|---|
| pack-priv | TypeConverterFactory(final Iterable<? extends GuardingTypeConverterFactory>
the factories, final MethodTypeConversionStrategy GuardingTypeConverterFactory instances to compose.conversion strategy for automatic type conversions. After
autoConversionStrategy)asType(java. has applied all custom
conversions to a method handle, it still needs to effect
method invocation conversions that
can usually be automatically applied as per
java..
However, sometimes language runtimes will want to customize even those conversions for their own call
sites. A typical example is allowing unboxing of null return values, which is by default prohibited by
ordinary MethodHandles.asType. In this case, a language runtime can install its own custom
automatic conversion strategy, that can deal with null values. Note that when the strategy's
MethodTypeConversionStrategy#asType(java.
is invoked, the custom language conversions will already have been applied to the method handle, so by
design the difference between the handle's current method type and the desired final type will always
only be ones that can be subjected to method invocation conversions. Can be null, in which case no
custom strategy is employed.Creates a new type converter factory from the available |
| Modifier and Type | Method and Description |
|---|---|
| private static MethodHandle | |
| pack-priv MethodHandle | Returns: a method handle that is a suitable combination ofMethodHandle#asType(MethodType),
MethodTypeConversionStrategy#asType(MethodHandle, MethodType), and
MethodHandles#filterArguments(MethodHandle, int, MethodHandle. with
GuardingTypeConverterFactory produced type converters as filters.target method handle handle, final MethodType the types of source arguments fromType)Similar to |
| pack-priv static boolean | Returns: true if it's safe to let MethodHandles.convertArguments() to handle this conversion.convert from this class fromType, final Class<?> convert to this class toType)Determines whether it's safe to perform an automatic conversion between the source and target class. |
| pack-priv boolean | Returns: true if there can be a conversion, false if there can not.the source type for the conversion from, final Class<?> the target type for the conversion to)Returns true if there might exist a conversion between the requested types (either an automatic JVM conversion,
or one provided by any available |
| pack-priv ConversionComparator. | Returns: one of Comparison constants that establish which - if any - of the target types is preferable for the conversion.the source type. sourceType, final Class<?> one potential target type targetType1, final Class<?> another potential target type. targetType2)Determines which of the two type conversions from a source type to the two target types is preferred. |
| pack-priv static MethodHandle | createConverter(final Class<?> sourceType, final Class<?> targetType, GuardingTypeConverterFactory[] factories)
|
| pack-priv static MethodHandle | getCacheableTypeConverter(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap)
|
| pack-priv static MethodHandle | getCacheableTypeConverterNull(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap)
|
| pack-priv MethodHandle | Returns: a method handle performing the conversion.the type to convert from sourceType, final Class<?> the type to convert to targetType)Given a source and target type, returns a method handle that converts between them. |
| pack-priv static MethodHandle | getTypeConverterNull(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap)
|
| autoConversionStrategy | back to summary |
|---|---|
| private final MethodTypeConversionStrategy autoConversionStrategy | |
| canConvert | back to summary |
|---|---|
| private final BiClassValue<Boolean> canConvert | |
| comparators | back to summary |
|---|---|
| private final ConversionComparator[] comparators | |
| converterIdentityMap | back to summary |
|---|---|
| private final BiClassValue<MethodHandle> converterIdentityMap | |
| converterMap | back to summary |
|---|---|
| private final BiClassValue<MethodHandle> converterMap | |
| IDENTITY_CONVERSION | back to summary |
|---|---|
| pack-priv static final MethodHandle IDENTITY_CONVERSION | |
| TypeConverterFactory | back to summary |
|---|---|
| pack-priv TypeConverterFactory(final Iterable<? extends GuardingTypeConverterFactory> factories, final MethodTypeConversionStrategy autoConversionStrategy) Creates a new type converter factory from the available
| |
| applyConverters | back to summary |
|---|---|
| private static MethodHandle applyConverters(final MethodHandle handle, final int pos, final List<MethodHandle> converters) | |
| asType | back to summary |
|---|---|
| pack-priv MethodHandle asType(final MethodHandle handle, final MethodType fromType) Similar to
| |
| canAutoConvert | back to summary |
|---|---|
| pack-priv static boolean canAutoConvert(final Class<?> fromType, final Class<?> toType) Determines whether it's safe to perform an automatic conversion between the source and target class. | |
| canConvert | back to summary |
|---|---|
| pack-priv boolean canConvert(final Class<?> from, final Class<?> to) Returns true if there might exist a conversion between the requested types (either an automatic JVM conversion,
or one provided by any available | |
| compareConversion | back to summary |
|---|---|
| pack-priv ConversionComparator. Determines which of the two type conversions from a source type to the two target types is preferred. This is
used for dynamic overloaded method resolution. If the source type is convertible to exactly one target type with
a method invocation conversion, it is chosen, otherwise available
| |
| createConverter | back to summary |
|---|---|
| pack-priv static MethodHandle createConverter(final Class<?> sourceType, final Class<?> targetType, GuardingTypeConverterFactory[] factories) | |
| getCacheableTypeConverter | back to summary |
|---|---|
| pack-priv static MethodHandle getCacheableTypeConverter(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap) | |
| getCacheableTypeConverterNull | back to summary |
|---|---|
| pack-priv static MethodHandle getCacheableTypeConverterNull(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap) | |
| getTypeConverter | back to summary |
|---|---|
| pack-priv MethodHandle getTypeConverter(final Class<?> sourceType, final Class<?> targetType) Given a source and target type, returns a method handle that converts between them. Never returns null; in worst case it will return an identity conversion (that might fail for some values at runtime). You can use this method if you have a piece of your program that is written in Java, and you need to reuse existing type conversion machinery in a non-invokedynamic context.
| |
| getTypeConverterNull | back to summary |
|---|---|
| pack-priv static MethodHandle getTypeConverterNull(final Class<?> sourceType, final Class<?> targetType, final BiClassValue<MethodHandle> converterMap) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv volatile boolean | |
| pack-priv volatile boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public MethodHandles. |
| closed | back to summary |
|---|---|
| pack-priv volatile boolean closed | |
| returnedLookup | back to summary |
|---|---|
| pack-priv volatile boolean returnedLookup | |
| LookupSupplier | back to summary |
|---|---|
| private LookupSupplier() | |
| get | back to summary |
|---|---|
| public MethodHandles. Implements java. Doc from java. Gets a result.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final MethodHandle |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| converter | back to summary |
|---|---|
| pack-priv final MethodHandle converter | |
| NotCacheableConverter | back to summary |
|---|---|
| pack-priv NotCacheableConverter(final MethodHandle converter) | |