Examples of changeReturnType()


Examples of java.lang.invoke.MethodType.changeReturnType()

        } else {
          newType = MethodType.genericMethodType(
              parameters.size() + 1, method.isVarArgs());
        }
        if (method.getReturnType() == Void.class) {
          newType = newType.changeReturnType(void.class);
        }
        methodHandle = new ConstantCallSite(MethodHandles.lookup()
            .unreflect(method).asType(newType)
            .asSpreader(Object[].class, newType.parameterCount()))
            .dynamicInvoker();
View Full Code Here

Examples of java.lang.invoke.MethodType.changeReturnType()

                relinkCount));
        // Make a MH that gathers all arguments to the invocation into an Object[]
        final MethodType type = callSite.getDescriptor().getMethodType();
        final MethodHandle collectingRelinker = boundRelinker.asCollector(Object[].class, type.parameterCount());
        return MethodHandles.foldArguments(MethodHandles.exactInvoker(type), collectingRelinker.asType(
                type.changeReturnType(MethodHandle.class)));
    }

    /**
     * Relinks a call site conforming to the invocation arguments.
     *
 
View Full Code Here

Examples of java.lang.invoke.MethodType.changeReturnType()

                //   foldArguments(guardWithTest(isNotNull, invoke(get_handle), null|nextComponent.invocation), get_getter_handle)
                // only with a bunch of method signature adjustments. Basically, retrieve method getter
                // AnnotatedDynamicMethod; if it is non-null, invoke its "handle" field, otherwise either return null,
                // or delegate to next component's invocation.

                final MethodHandle typedGetter = linkerServices.asType(getPropertyGetterHandle, type.changeReturnType(
                        AnnotatedDynamicMethod.class));
                final MethodHandle callSiteBoundMethodGetter = MethodHandles.insertArguments(
                        GET_ANNOTATED_METHOD, 1, callSiteDescriptor.getLookup());
                final MethodHandle callSiteBoundInvoker = MethodHandles.filterArguments(GETTER_INVOKER, 0,
                        callSiteBoundMethodGetter);
View Full Code Here

Examples of java.lang.invoke.MethodType.changeReturnType()

                // What's below is basically:
                // foldArguments(guardWithTest(isNotNull, identity, nextComponent.invocation), getter) only with a
                // bunch of method signature adjustments. Basically, execute method getter; if it returns a non-null
                // DynamicMethod, use identity to return it, otherwise delegate to nextComponent's invocation.

                final MethodHandle typedGetter = linkerServices.asType(getDynamicMethod, type.changeReturnType(
                        DynamicMethod.class));
                // Since it is part of the foldArgument() target, it will have extra args that we need to drop.
                final MethodHandle returnMethodHandle = linkerServices.asType(MethodHandles.dropArguments(
                        DYNAMIC_METHOD_IDENTITY, 1, type.parameterList()), type.insertParameterTypes(0,
                                DynamicMethod.class));
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.