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

The following examples show how to use jdk.internal.dynalink.linker.LinkerServices#asTypeLosslessReturn() . 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: OverloadedMethod.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 2
Source File: OverloadedMethod.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 3
Source File: OverloadedMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 4
Source File: OverloadedMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 5
Source File: OverloadedMethod.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 6
Source File: OverloadedMethod.java    From jdk8u_nashorn with GNU General Public License v2.0 5 votes vote down vote up
OverloadedMethod(final List<MethodHandle> methodHandles, final OverloadedDynamicMethod parent, final MethodType callSiteType,
        final LinkerServices linkerServices) {
    this.parent = parent;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(MethodHandle mh: methodHandles) {
        if(mh.isVarargsCollector()) {
            final MethodHandle asFixed = mh.asFixedArity();
            if(argNum == asFixed.type().parameterCount()) {
                fixArgMethods.add(asFixed);
            }
            varArgMethods.add(mh);
        } else {
            fixArgMethods.add(mh);
        }
    }
    fixArgMethods.trimToSize();
    varArgMethods.trimToSize();

    final MethodHandle bound = SELECT_METHOD.bindTo(this);
    final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
            callSiteType.changeReturnType(MethodHandle.class));
    invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
            MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
 
Example 7
Source File: SingleDynamicMethod.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
 
Example 8
Source File: SingleDynamicMethod.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
 
Example 9
Source File: SingleDynamicMethod.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
 
Example 10
Source File: SingleDynamicMethod.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
 
Example 11
Source File: SingleDynamicMethod.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}
 
Example 12
Source File: SingleDynamicMethod.java    From jdk8u_nashorn with GNU General Public License v2.0 4 votes vote down vote up
private static MethodHandle createConvertingInvocation(final MethodHandle sizedMethod,
        final LinkerServices linkerServices, final MethodType callSiteType) {
    return linkerServices.asTypeLosslessReturn(sizedMethod, callSiteType);
}