Java Code Examples for jdk.internal.dynalink.linker.LinkerServices#canConvert()

The following examples show how to use jdk.internal.dynalink.linker.LinkerServices#canConvert() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: nashorn   File: BeanLinker.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static MethodHandle convertArgToInt(MethodHandle mh, LinkerServices ls, 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;
}
 
Example 2
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;
}
 
Example 3
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;
}
 
Example 4
private static MethodHandle convertArgToInt(MethodHandle mh, LinkerServices ls, 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;
}
 
Example 5
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;
}
 
Example 6
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;
}
 
Example 7
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 8
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 9
private static boolean isApplicableDynamically(LinkerServices linkerServices, Class<?> callSiteType,
        Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 10
private static boolean canConvert(LinkerServices ls, Class<?> from, Class<?> to) {
    if(from == NULL_CLASS) {
        return !to.isPrimitive();
    }
    return ls == null ? TypeUtilities.isMethodInvocationConvertible(from, to) : ls.canConvert(from, to);
}
 
Example 11
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 12
private static boolean isApplicableDynamically(LinkerServices linkerServices, Class<?> callSiteType,
        Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 13
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 14
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 15
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);
}
 
Example 16
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, Class<?> to, Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 17
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, final Class<?> to, final Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 18
private static boolean canConvert(LinkerServices ls, Class<?> from, Class<?> to) {
    if(from == NULL_CLASS) {
        return !to.isPrimitive();
    }
    return ls == null ? TypeUtilities.isMethodInvocationConvertible(from, to) : ls.canConvert(from, to);
}
 
Example 19
private static boolean canConvert(LinkerServices ls, Class<?> from, Class<?> to) {
    if(from == NULL_CLASS) {
        return !to.isPrimitive();
    }
    return ls == null ? TypeUtilities.isMethodInvocationConvertible(from, to) : ls.canConvert(from, to);
}
 
Example 20
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}