/** * Sole factory method to find or create an interned method type. * * @param rtype desired return type * @param ptypes desired parameter types * @param trusted whether the ptypes can be used without cloning * @return the unique method type of the desired structure */ /*trusted*/ static MethodType makeImpl(Class<?> rtype, Class<?>[] ptypes, boolean trusted) { if (ptypes.length == 0) { ptypes = NO_PTYPES; trusted = true; } MethodType mt1 = new MethodType(rtype, ptypes); MethodType mt0; synchronized (internTable) { mt0 = internTable.get(mt1); if (mt0 != null) return mt0; } if (!trusted) // defensively copy the array passed in by the user mt1 = new MethodType(rtype, ptypes.clone()); // promote the object to the Real Thing, and reprobe MethodTypeForm form = MethodTypeForm.findForm(mt1); mt1.form = form; if (form.erasedType == mt1) { // This is a principal (erased) type; show it to the JVM. MethodHandleNatives.init(mt1); } synchronized (internTable) { mt0 = internTable.get(mt1); if (mt0 != null) return mt0; internTable.put(mt1, mt1); } return mt1; }
private static LambdaForm preparedLambdaForm(MethodType mtype, int which) { LambdaForm lform = mtype.form().cachedLambdaForm(which); if (lform != null) return lform; lform = makePreparedLambdaForm(mtype, which); return mtype.form().setCachedLambdaForm(which, lform); }