This is a mirror of official site: http://jasper-net.blogspot.com/

MethodHandle From C#

| Monday, August 8, 2011
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

0 comments: