java.lang.invoke.LambdaForm.NamedFunction Java Examples
The following examples show how to use
java.lang.invoke.LambdaForm.NamedFunction.
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: BoundMethodHandle.java From hottub with GNU General Public License v2.0 | 5 votes |
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; }
Example #2
Source File: BoundMethodHandle.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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; }
Example #3
Source File: BoundMethodHandle.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #4
Source File: BoundMethodHandle.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** * 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; }
Example #5
Source File: BoundMethodHandle.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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; }
Example #6
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #7
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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]; }
Example #8
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example #9
Source File: BoundMethodHandle.java From Java8CN with Apache License 2.0 | 5 votes |
/** * 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; }
Example #10
Source File: BoundMethodHandle.java From Java8CN with Apache License 2.0 | 5 votes |
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]; }
Example #11
Source File: BoundMethodHandle.java From Java8CN with Apache License 2.0 | 5 votes |
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; }
Example #12
Source File: BoundMethodHandle.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #13
Source File: BoundMethodHandle.java From hottub with GNU General Public License v2.0 | 5 votes |
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]; }
Example #14
Source File: BoundMethodHandle.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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]; }
Example #15
Source File: BoundMethodHandle.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #16
Source File: BoundMethodHandle.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #17
Source File: BoundMethodHandle.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #18
Source File: BoundMethodHandle.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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]; }
Example #19
Source File: BoundMethodHandle.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example #20
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #21
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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]; }
Example #22
Source File: BoundMethodHandle.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example #23
Source File: BoundMethodHandle.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * 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; }
Example #24
Source File: BoundMethodHandle.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #25
Source File: BoundMethodHandle.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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]; }
Example #26
Source File: BoundMethodHandle.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example #27
Source File: BoundMethodHandle.java From JDKSourceCode1.8 with MIT License | 5 votes |
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]; }
Example #28
Source File: BoundMethodHandle.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * 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; }
Example #29
Source File: BoundMethodHandle.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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; }
Example #30
Source File: BoundMethodHandle.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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]; }