« Return to Thread: Java subclasses in Ruby

Re: Java subclasses in Ruby

by Charles Oliver Nutter-2 :: Rate this Message:

Reply to Author | View in Thread

backspaces wrote:

> In the jruby - dev forum I found:
>
> Kresten Krab Thorup (Trifork) wrote:
>> So, I just submitted fix for JRUBY-71 (against current trunk, 2225).  
>> This allows one to write a subclass of a Java class in ruby, override/
>> extend methods, call super, etc., and pass such objects back out to  
>> java.
>>
>> <snip>
>>
>> Enjoy!
>>
>> Kresten
>>
>
> But I've seen other emails which indicate that JRuby/Java interoperability
> in terms of subclassing is not working.
>
> 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.

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.

> My specific interest is to use a graphics library, Processing.org, which
> requires me to subclass its PApplet class, and have that subclass be
> callable from the Processing library, .. i.e. from Java.

- Charlie


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Java subclasses in Ruby