Exemplo n.º 1
0
        public static T GetDelegateForInvoke <T>(global::java.lang.invoke.MethodHandle h, ref InvokeCache <T> cache)
            where T : class
        {
#if FIRST_PASS
            return(null);
#else
            if (cache.type == h.type() && cache.del != null)
            {
                return(cache.del);
            }
            T del = h.vmtarget as T;
            if (del == null)
            {
                global::java.lang.invoke.MethodHandle adapter = global::java.lang.invoke.MethodHandles.exactInvoker(h.type());
                if (h.isVarargsCollector())
                {
                    adapter = adapter.asVarargsCollector(h.type().parameterType(h.type().parameterCount() - 1));
                }
                del = (T)adapter.asType(MethodHandleUtil.GetDelegateMethodType(typeof(T))).vmtarget;
                if (Interlocked.CompareExchange(ref cache.type, h.type(), null) == null)
                {
                    cache.del = del;
                }
            }
            return(del);
#endif
        }
Exemplo n.º 2
0
        public static T GetDelegateForInvokeExact <T>(global::java.lang.invoke.MethodHandle h)
            where T : class
        {
#if FIRST_PASS
            return(null);
#else
            T del = h._invokeExactDelegate as T;
            if (del == null)
            {
                del = MethodHandleUtil.GetDelegateForInvokeExact <T>(h);
            }
            return(del);
#endif
        }
Exemplo n.º 3
0
        public static T GetDelegateForInvokeExact <T>(global::java.lang.invoke.MethodHandle h)
            where T : class
        {
#if FIRST_PASS
            return(null);
#else
            T del = h.vmtarget as T;
            if (del == null)
            {
                throw new global::java.lang.invoke.WrongMethodTypeException();
            }
            return(del);
#endif
        }
Exemplo n.º 4
0
        public static T GetDelegateForInvoke <T>(global::java.lang.invoke.MethodHandle h, java.lang.invoke.MethodType realType, ref InvokeCache <T> cache)
            where T : class
        {
#if FIRST_PASS
            return(null);
#else
            T del;
            if (cache.Type == h.type() && (del = (h.isVarargsCollector() ? cache.varArg : cache.fixedArg)) != null)
            {
                return(del);
            }
            del = h.form.vmentry.vmtarget as T;
            if (del == null)
            {
                global::java.lang.invoke.MethodHandle adapter = global::java.lang.invoke.MethodHandles.exactInvoker(h.type());
                if (h.isVarargsCollector())
                {
                    adapter = adapter.asVarargsCollector(h.type().parameterType(h.type().parameterCount() - 1));
                }
                // if realType is set, the delegate contains erased unloadable types
                if (realType != null)
                {
                    adapter = adapter.asType(realType.insertParameterTypes(0, [email protected] <java.lang.invoke.MethodHandle> .Value)).asFixedArity();
                }
                adapter = adapter.asType(MethodHandleUtil.GetDelegateMethodType(typeof(T)));
                del     = GetDelegateForInvokeExact <T>(adapter);
                if (cache.TrySetType(h.type()))
                {
                    if (h.isVarargsCollector())
                    {
                        cache.varArg = del;
                    }
                    else
                    {
                        cache.fixedArg = del;
                    }
                }
            }
            return(del);
#endif
        }
Exemplo n.º 5
0
        public static T GetDelegateForInvoke <T>(global::java.lang.invoke.MethodHandle h, ref InvokeCache <T> cache)
            where T : class
        {
#if FIRST_PASS
            return(null);
#else
            T del;
            if (cache.Type == h.type() && (del = (h.isVarargsCollector() ? cache.varArg : cache.fixedArg)) != null)
            {
                return(del);
            }
            del = h.form.vmentry.vmtarget as T;
            if (del == null)
            {
                global::java.lang.invoke.MethodHandle adapter = global::java.lang.invoke.MethodHandles.exactInvoker(h.type());
                if (h.isVarargsCollector())
                {
                    adapter = adapter.asVarargsCollector(h.type().parameterType(h.type().parameterCount() - 1));
                }
                adapter = adapter.asType(MethodHandleUtil.GetDelegateMethodType(typeof(T)));
                del     = GetDelegateForInvokeExact <T>(adapter);
                if (cache.TrySetType(h.type()))
                {
                    if (h.isVarargsCollector())
                    {
                        cache.varArg = del;
                    }
                    else
                    {
                        cache.fixedArg = del;
                    }
                }
            }
            return(del);
#endif
        }