當前位置: 首頁>>代碼示例>>Java>>正文


Java MethodHandle.asFixedArity方法代碼示例

本文整理匯總了Java中java.lang.invoke.MethodHandle.asFixedArity方法的典型用法代碼示例。如果您正苦於以下問題:Java MethodHandle.asFixedArity方法的具體用法?Java MethodHandle.asFixedArity怎麽用?Java MethodHandle.asFixedArity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.lang.invoke.MethodHandle的用法示例。


在下文中一共展示了MethodHandle.asFixedArity方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: OverloadedMethod

import java.lang.invoke.MethodHandle; //導入方法依賴的package包/類
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 = MethodHandles.foldArguments(MethodHandles.exactInvoker(this.callSiteType), collecting);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:OverloadedMethod.java

示例2: OverloadedMethod

import java.lang.invoke.MethodHandle; //導入方法依賴的package包/類
OverloadedMethod(final List<MethodHandle> methodHandles,
        final OverloadedDynamicMethod parent,
        final ClassLoader callSiteClassLoader,
        final MethodType callSiteType,
        final LinkerServices linkerServices,
        final SecureLookupSupplier lookupSupplier) {
    this.parent = parent;
    this.callSiteClassLoader = callSiteClassLoader;
    final Class<?> commonRetType = getCommonReturnType(methodHandles);
    this.callSiteType = callSiteType.changeReturnType(commonRetType);
    this.linkerServices = linkerServices;
    this.lookupSupplier = lookupSupplier;

    fixArgMethods = new ArrayList<>(methodHandles.size());
    varArgMethods = new ArrayList<>(methodHandles.size());
    final int argNum = callSiteType.parameterCount();
    for(final 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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:37,代碼來源:OverloadedMethod.java


注:本文中的java.lang.invoke.MethodHandle.asFixedArity方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。