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 File: BeanLinker.java    From nashorn with 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
Source File: BeanLinker.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: BeanLinker.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: BeanLinker.java    From openjdk-8-source with 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 5
Source File: BeanLinker.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: BeanLinker.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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
Source File: OverloadedDynamicMethod.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 8
Source File: OverloadedDynamicMethod.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isApplicableDynamically(LinkerServices linkerServices, Class<?> callSiteType,
        Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 9
Source File: ClassString.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
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 10
Source File: SingleDynamicMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
@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 11
Source File: OverloadedDynamicMethod.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isApplicableDynamically(LinkerServices linkerServices, Class<?> callSiteType,
        Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 12
Source File: OverloadedDynamicMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}
 
Example 13
Source File: SingleDynamicMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@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 14
Source File: ClassString.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
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 15
Source File: SingleDynamicMethod.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
@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 16
Source File: SingleDynamicMethod.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unused")
private static boolean canConvertTo(final LinkerServices linkerServices, Class<?> to, Object obj) {
    return obj == null ? false : linkerServices.canConvert(obj.getClass(), to);
}
 
Example 17
Source File: SingleDynamicMethod.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
@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
Source File: ClassString.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
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
Source File: ClassString.java    From nashorn with GNU General Public License v2.0 4 votes vote down vote up
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
Source File: OverloadedDynamicMethod.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static boolean isApplicableDynamically(final LinkerServices linkerServices, final Class<?> callSiteType,
        final Class<?> methodType) {
    return TypeUtilities.isPotentiallyConvertible(callSiteType, methodType)
            || linkerServices.canConvert(callSiteType, methodType);
}