Skip to content
headius edited this page Feb 15, 2013 · 1 revision

The general strategy for Java integration lives somewhere between normal Ruby compilation with RubyFlux and JRuby's integration strategy.

Because RubyFlux compiles all calls into normal virtual Java method invocations, we need a way to dynamically link Java classes. The basic strategy will work like this:

  • As with all other calls, method names are pushed up into RObject.
  • Java objects entering RubyFlux will get a standard wrapper that descends from RObject
  • This "RJavaObject" wrapper will override all RObject methods with lazy reflection-based invocation
    1. Look up method on wrapped object
    2. Cache method for next time
    3. Subsequent calls check target, arg types to validate cache

This mechanism will provide similar Java integration performance to JRuby. On platforms that have Java 7 MethodHandle support, reflection could be replaced with MethodHandle invocations instead.

Clone this wiki locally