blog post on invokedynamic
forax at univ-mlv.fr
Tue Feb 17 05:15:25 PST 2009
Tobias Ivarsson a écrit :
> On Tue, Feb 17, 2009 at 11:20 AM, Rémi Forax <forax at univ-mlv.fr
> <mailto:forax at univ-mlv.fr>> wrote:
> Create a MOP is you have MethodHandles is more easier than without :)
> But how to handle the case where you want to call a ruby method with
> a PHP object.
> This is what Interface Injection aims to solve.
After my FOSDEM presentation,
Someone (sorry I am not able to recall who) ask me how to recognize if
an object is a
PHP one or a Ruby one, I have answered that interface injection should
I'm glad that my answer was not a complete mistake.
> When the JRuby runtime recevies an object from PHP it casts it to
> IRubyObject (the main JRuby type) which is an injectable interface. If
> the class of the object does not already implement IRubyObject the
> injector for the interface is invoked. The injector is a regular java
> object that has a method for providing MethodHandles that make up the
> implementation methods for the interface. As in the case with the
> bootstrap method in invokedynamic this method can do whatever the
> language implementor chooses to get or define these MethodHandles. My
> recommendation in this case is for the injector to get the meta object
> from the PHP object and use that to lookup the MethodHandles for each
> capability that JRuby uses, and use default implementations where the
> meta object does not support the capability.
And the idea of the MOP is that the meta object should have the same
interface for all dynamic languages.
> I intend to contribute work on this to the dynalang project when the
> work on interface injection is done, and the rest of my work queue is
> empty enough. Hopefully in April, after PyCon.
More information about the mlvm-dev