本文整理汇总了Java中jdk.internal.dynalink.linker.LinkerServices.canConvert方法的典型用法代码示例。如果您正苦于以下问题:Java LinkerServices.canConvert方法的具体用法?Java LinkerServices.canConvert怎么用?Java LinkerServices.canConvert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.internal.dynalink.linker.LinkerServices
的用法示例。
在下文中一共展示了LinkerServices.canConvert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertArgToInt
import jdk.internal.dynalink.linker.LinkerServices; //导入方法依赖的package包/类
private static MethodHandle convertArgToInt(final MethodHandle mh, final LinkerServices ls, final CallSiteDescriptor desc) {
final Class<?> sourceType = desc.getMethodType().parameterType(1);
if(TypeUtilities.isMethodInvocationConvertible(sourceType, Number.class)) {
return mh;
} else if(ls.canConvert(sourceType, Number.class)) {
final MethodHandle converter = ls.getTypeConverter(sourceType, Number.class);
return MethodHandles.filterArguments(mh, 1, converter.asType(converter.type().changeReturnType(
mh.type().parameterType(1))));
}
return mh;
}
示例2: canConvertTo
import jdk.internal.dynalink.linker.LinkerServices; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
示例3: canConvert
import jdk.internal.dynalink.linker.LinkerServices; //导入方法依赖的package包/类
private static boolean canConvert(final LinkerServices ls, final Class<?> from, final Class<?> to) {
if(from == NULL_CLASS) {
return !to.isPrimitive();
}
return ls == null ? TypeUtilities.isMethodInvocationConvertible(from, to) : ls.canConvert(from, to);
}
示例4: isApplicableDynamically
import jdk.internal.dynalink.linker.LinkerServices; //导入方法依赖的package包/类
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
final Class<?> methodType) {
return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
|| linkerServices.canConvert(callSiteType, methodType);
}