当前位置: 首页>>代码示例>>Java>>正文


Java NamedFunction类代码示例

本文整理汇总了Java中java.lang.invoke.LambdaForm.NamedFunction的典型用法代码示例。如果您正苦于以下问题:Java NamedFunction类的具体用法?Java NamedFunction怎么用?Java NamedFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NamedFunction类属于java.lang.invoke.LambdaForm包,在下文中一共展示了NamedFunction类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getterFunction

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
/**
 * Return a {@link LambdaForm.Name} containing a {@link LambdaForm.NamedFunction} that
 * represents a MH bound to a generic invoker, which in turn forwards to the corresponding
 * getter.
 */
NamedFunction getterFunction(int i) {
    NamedFunction nf = nominalGetters[i];
    assert(nf.memberDeclaringClassOrNull() == fieldHolder());
    assert(nf.returnType() == fieldType(i));
    return nf;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:12,代码来源:BoundMethodHandle.java

示例2: SpeciesData

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
private SpeciesData(String types, Class<? extends BoundMethodHandle> clazz) {
    this.typeChars = types;
    this.typeCodes = basicTypes(types);
    this.clazz = clazz;
    if (!INIT_DONE) {
        this.constructor = new MethodHandle[1];  // only one ctor
        this.getters = new MethodHandle[types.length()];
        this.nominalGetters = new NamedFunction[types.length()];
    } else {
        this.constructor = Factory.makeCtors(clazz, types, null);
        this.getters = Factory.makeGetters(clazz, types, null);
        this.nominalGetters = Factory.makeNominalGetters(types, null, this.getters);
    }
    this.extensions = new SpeciesData[ARG_TYPE_LIMIT];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:BoundMethodHandle.java

示例3: makeNominalGetters

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
static NamedFunction[] makeNominalGetters(String types, NamedFunction[] nfs, MethodHandle[] getters) {
    if (nfs == null)  nfs = new NamedFunction[types.length()];
    for (int i = 0; i < nfs.length; ++i) {
        nfs[i] = new NamedFunction(getters[i]);
    }
    return nfs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:8,代码来源:BoundMethodHandle.java

示例4: SpeciesData

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
SpeciesData(String types, Class<? extends BoundMethodHandle> clazz) {
    this.typeChars = types;
    this.typeCodes = basicTypes(types);
    this.clazz = clazz;
    if (!INIT_DONE) {
        this.constructor = new MethodHandle[1];  // only one ctor
        this.getters = new MethodHandle[types.length()];
        this.nominalGetters = new NamedFunction[types.length()];
    } else {
        this.constructor = Factory.makeCtors(clazz, types, null);
        this.getters = Factory.makeGetters(clazz, types, null);
        this.nominalGetters = Factory.makeNominalGetters(types, null, this.getters);
    }
    this.extensions = new SpeciesData[ARG_TYPE_LIMIT];
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:BoundMethodHandle.java

示例5: linkConstructor

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
/**
 * Wrap a constructor call in a {@link LambdaForm}.
 *
 * If constructors ({@code <init>} methods) are called in LFs, problems might arise if the LFs
 * are turned into bytecode, because the call to the allocator is routed through an MH, and the
 * verifier cannot find a {@code NEW} instruction preceding the {@code INVOKESPECIAL} to
 * {@code <init>}. To avoid this, we add an indirection by invoking {@code <init>} through
 * {@link MethodHandle#linkToSpecial}.
 *
 * The last {@link LambdaForm#Name Name} in the argument's form is expected to be the {@code void}
 * result of the {@code <init>} invocation. This entry is replaced.
 */
private static MethodHandle linkConstructor(MethodHandle cmh) {
    final LambdaForm lf = cmh.form;
    final int initNameIndex = lf.names.length - 1;
    final Name initName = lf.names[initNameIndex];
    final MemberName ctorMN = initName.function.member;
    final MethodType ctorMT = ctorMN.getInvocationType();

    // obtain function member (call target)
    // linker method type replaces initial parameter (BMH species) with BMH to avoid naming a species (anonymous class!)
    final MethodType linkerMT = ctorMT.changeParameterType(0, BoundMethodHandle.class).appendParameterTypes(MemberName.class);
    MemberName linkerMN = new MemberName(MethodHandle.class, "linkToSpecial", linkerMT, REF_invokeStatic);
    try {
        linkerMN = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linkerMN, null, NoSuchMethodException.class);
        assert(linkerMN.isStatic());
    } catch (ReflectiveOperationException ex) {
        throw newInternalError(ex);
    }
    // extend arguments array
    Object[] newArgs = Arrays.copyOf(initName.arguments, initName.arguments.length + 1);
    newArgs[newArgs.length - 1] = ctorMN;
    // replace function
    final NamedFunction nf = new NamedFunction(linkerMN);
    final Name linkedCtor = new Name(nf, newArgs);
    linkedCtor.initIndex(initNameIndex);
    lf.names[initNameIndex] = linkedCtor;
    return cmh;
}
 
开发者ID:ZhaoX,项目名称:jdk-1.7-annotated,代码行数:40,代码来源:BoundMethodHandle.java

示例6: linkConstructor

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
/**
 * Wrap a constructor call in a {@link LambdaForm}.
 *
 * If constructors ({@code <init>} methods) are called in LFs, problems might arise if the LFs
 * are turned into bytecode, because the call to the allocator is routed through an MH, and the
 * verifier cannot find a {@code NEW} instruction preceding the {@code INVOKESPECIAL} to
 * {@code <init>}. To avoid this, we add an indirection by invoking {@code <init>} through
 * {@link MethodHandle#linkToSpecial}.
 *
 * The last {@link LambdaForm.Name Name} in the argument's form is expected to be the {@code void}
 * result of the {@code <init>} invocation. This entry is replaced.
 */
private static MethodHandle linkConstructor(MethodHandle cmh) {
    final LambdaForm lf = cmh.form;
    final int initNameIndex = lf.names.length - 1;
    final Name initName = lf.names[initNameIndex];
    final MemberName ctorMN = initName.function.member;
    final MethodType ctorMT = ctorMN.getInvocationType();

    // obtain function member (call target)
    // linker method type replaces initial parameter (BMH species) with BMH to avoid naming a species (anonymous class!)
    final MethodType linkerMT = ctorMT.changeParameterType(0, BoundMethodHandle.class).appendParameterTypes(MemberName.class);
    MemberName linkerMN = new MemberName(MethodHandle.class, "linkToSpecial", linkerMT, REF_invokeStatic);
    try {
        linkerMN = MemberName.getFactory().resolveOrFail(REF_invokeStatic, linkerMN, null, NoSuchMethodException.class);
        assert(linkerMN.isStatic());
    } catch (ReflectiveOperationException ex) {
        throw newInternalError(ex);
    }
    // extend arguments array
    Object[] newArgs = Arrays.copyOf(initName.arguments, initName.arguments.length + 1);
    newArgs[newArgs.length - 1] = ctorMN;
    // replace function
    final NamedFunction nf = new NamedFunction(linkerMN);
    final Name linkedCtor = new Name(nf, newArgs);
    linkedCtor.initIndex(initNameIndex);
    lf.names[initNameIndex] = linkedCtor;
    return cmh;
}
 
开发者ID:RedlineResearch,项目名称:OLD-OpenJDK8,代码行数:40,代码来源:BoundMethodHandle.java

示例7: getterFunctions

import java.lang.invoke.LambdaForm.NamedFunction; //导入依赖的package包/类
NamedFunction[] getterFunctions() {
    return nominalGetters;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:4,代码来源:BoundMethodHandle.java


注:本文中的java.lang.invoke.LambdaForm.NamedFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。