My question is related to closure conversion. I want to test a proc that implements a functional interface from jruby code.
I have a simple proc like
proc { print 'hey!' }
to implement a java functional interface like
public void doStuff()
Since the client object is a Java object that is
public class MyClient {
private MyInterface iface;
public MyClient(MyInterface iface) {
this.iface = iface;
}
public void doHighLevelStuff() {
this.iface.doStuff();
}
}
it works right, since jruby manages to "cast" the proc into a java functional interface. So, this part it's ok.
My problem is testing this code, calling it from jruby. I don't know how to tell jruby to treat that proc as an implementation of MyInterface
to be able to call the actual method doStuff
instead of the ruby specification call
.
So, the question is how to tell jruby to treat a proc as a given java interface.