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 }
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 }