Monday, August 08, 2011

MethodHandle From C#

using java.lang.invoke;

class Program {
  static void Main() {
    MethodType mt = MethodType.methodType(typeof(void), typeof(string), typeof(object[]));
    MethodHandle mh = MethodHandles.lookup().findStatic(typeof(System.Console), "WriteLine", mt);
    mh.invoke("{0} {1}", "Hello", "World");
  }
}

This now works, but it is not very efficient. Invoking a MethodHandle from Java is more efficient, because the call site signature is statically known in that case.

Read more: IKVM blog
QR: PermaLink.aspx?guid=f68aa0fb-9447-4aa5-8036-6415adf6fb02

Posted via email from Jasper-Net