-
Notifications
You must be signed in to change notification settings - Fork 25
Java Integration
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
- Look up method on wrapped object
- Cache method for next time
- 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.