Skip to main content

Javac + invokedynamic

Posted by forax on May 22, 2008 at 6:37 AM PDT

Just for fun, this morning, i've patched the java compiler
to be able to generate classes that use
invokedynamic instead of invokevirtual/invokeinterface when invoking
a method. following the JSR292 EDR

The patch is based on the source of the langtools repository of
the hotspot project, so to apply the patch, first clone the

  hg clone

An then apply the following patch
then run ant in langtools/make.

Now, you have a patched javac that will insert an
invokedynamic instead of an invokevirtual
when calling a method tagged by @InvokeDynamic.

import java.dyn.InvokeDynamic;

public class Test {
  public void m(String message) {
  public static void main(String[] args) {
    // here m is invoked dynamically
    new Test().m("hello invoke dynamic");

And now, how to run it.

Hum, good question, i'm afraid we have to wait the RI implementation
of JSR 292 :)

Or perhaps an enhanced version of the
IKVM Proof of Concept.



Related Topics >>