Charles Oliver Nutter-2 wrote:
backspaces wrote:
> In the jruby - dev forum I found:
> ...
> So two questions:
> 1 - Is the goal for JRuby to be able to have complete bi-directionality in
> terms of subclassing of Java classes? I.e. much the way quoted above?
> 2 - If so, does it currently work?
If by bi-directionality, you mean such subclasses are usable in both
Ruby and Java...yes, that is the intent. I believe it's *partially*
working, but this is going to be a big area of focus over the next
several months.
Yup, that's exactly my goal: I want to subclass a Java class within JRuby. The JRuby class will call the Java superclass methods for graphics primitives. And the Java superclass will call certain methods in the JRuby subclass for initialization and stepping the graphics through its animation. Specifically, the protocol is that the superclass will call two methods, setup() and draw() in the JRuby subclass.
If by bi-directionality, you mean both Ruby can extend Java and Java can
extend Ruby, well I'd argue the latter isn't possible with a dynamic
language. The subclass can never fulfill the contracts of the Ruby
superclass since it can't add and remove methods, can't be re-opened,
and so on. I believe Groovy supports this, but the superclass you extend
must be made quite a bit less dynamic, and the subclass still doesn't
support all the more dynamic features of Groovy. We'll support Ruby
extending Java, but I doubt we'll support the other direction.
- Charlie
I'm pretty sure I'll not need this level of sophistication. Actually it hadn't occurred to me!
-- Owen
"You can do Anything, but not Everything!"