Forum: JRuby Is there a nicer way to call Ruby method from Java?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0fa73332c8e4a3b06ea439fd3f034322?d=identicon&s=25 Ronald Fischer (rovf)
on 2016-01-13 14:58
I have in my Java class a variable of type IRubyObject, which actually
points to a RubyObject:

    // Java
    RubyObject ro = get_it_from_somewhere();
    ....
    IRubyObject iro = ro;

The RubyObject holds an object of some Ruby class, and this class in
turn has a method expecting one parameter (which is supposed to be a
string):

    # Ruby
    def myfunc(msg)
        ....
    end

I want to invoke this method from Java, and I'm not interested in the
return value. This is my code:

      // Java
      Ruby runtime = iro.getRuntime();
      ThreadContext currentContext = runtime.getCurrentContext();
      iro.callMethod(currentContext, "myfunc",
JavaEmbedUtils.javaToRuby(runtime, "string passed to myfunc"));

My question: Is it possible to code this a bit simpler?
This topic is locked and can not be replied to.