Examples of GuardedInvocation


Examples of org.dynalang.dynalink.linker.GuardedInvocation

        }

        @Override
        public GuardedInvocation getGuardedInvocation(LinkRequest request, LinkerServices linkerServices)
                throws Exception {
            final GuardedInvocation gi = super.getGuardedInvocation(request, linkerServices);
            if(gi != null) {
                return gi;
            }
            final CallSiteDescriptor desc = request.getCallSiteDescriptor();
            final String op = desc.getNameToken(CallSiteDescriptor.OPERATOR);
            if("new" == op && constructor != null) {
                final MethodHandle ctorInvocation = constructor.getInvocation(desc, linkerServices);
                if(ctorInvocation != null) {
                    return new GuardedInvocation(ctorInvocation, getClassGuard(desc.getMethodType()));
                }
            }
            return null;
        }
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

        final LinkerServices ls = new LinkerServicesImpl(new TypeConverterFactory(Collections.singleton(
                new GuardingTypeConverterFactory() {
                    @Override
                    public GuardedInvocation convertToType(Class<?> sourceType, Class<?> targetType) {
                        if(targetType == int.class) {
                            return new GuardedInvocation(new Lookup(MethodHandles.publicLookup()).findVirtual(
                                    Double.class, "intValue", MethodType.methodType(int.class)).asType(
                                            MethodType.methodType(int.class, sourceType)), Guards.isOfClass(
                                                    Double.class, MethodType.methodType(boolean.class, sourceType)));
                        }
                        return null;
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

        TypeBasedGuardingDynamicLinker linker = BeansLinker.getLinkerForClass(Test1.class);
        LinkerServices ls = LinkerServicesFactory.getLinkerServices(linker);


        Test1 test1 = new Test1();
        GuardedInvocation inv = linker.getGuardedInvocation(new LinkRequestImpl(
                CallSiteDescriptorFactory.create(MethodHandles.publicLookup(), "dyn:callMethod:add",
                        MethodType.methodType(Object.class, Object.class, Object.class, Object.class, Object.class, Object.class)),
                        false, null, null, null, null, null), ls);
        MethodHandle handle = inv.getInvocation();

        System.out.println(handle.invokeWithArguments(test1, 1, 2, 3, 4));
    }
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

            }
        } else {
            typedFixedKey = fixedKey;
        }

        final GuardedInvocation gi = gic.getGuardedInvocation();
        final Binder binder = new Binder(linkerServices, callSiteType, typedFixedKey);
        final MethodHandle invocation = gi.getInvocation();

        if(nextComponent == null) {
            return gic.replaceInvocation(binder.bind(invocation));
        }

        final MethodHandle checkGuard = convertArgToInt(invocation == SET_LIST_ELEMENT ? RANGE_CHECK_LIST :
            RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor);
        return nextComponent.compose(MethodHandles.guardWithTest(binder.bindTest(checkGuard),
                binder.bind(invocation), nextComponent.getGuardedInvocation().getInvocation()), gi.getGuard(),
                gic.getValidatorClass(), gic.getValidationType());
    }
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

    @Override
    public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest, final LinkerServices linkerServices)
            throws Exception {
        for(final GuardingDynamicLinker linker: linkers) {
            final GuardedInvocation invocation = linker.getGuardedInvocation(linkRequest, linkerServices);
            if(invocation != null) {
                return invocation;
            }
        }
        return null;
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

        return new GuardedInvocationComponent(guardedInvocation.replaceMethods(newInvocation,
                newGuard), validator);
    }

    private GuardedInvocationComponent(MethodHandle invocation, MethodHandle guard, Validator validator) {
        this(new GuardedInvocation(invocation, guard), validator);
    }
View Full Code Here

Examples of org.dynalang.dynalink.linker.GuardedInvocation

            final MethodHandle invocation = ((DynamicMethod)receiver).getInvocation(
                    CallSiteDescriptorFactory.dropParameterTypes(desc, 0, 1), linkerServices);
            if(invocation == null) {
                return null;
            }
            return new GuardedInvocation(MethodHandles.dropArguments(invocation, 0,
                    desc.getMethodType().parameterType(0)), Guards.getIdentityGuard(receiver));
        }
        return null;
    }
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.