Subclasses of interface-only Java proxy classes don't inherit correctly
-----------------------------------------------------------------------

                 Key: JRUBY-921
                 URL: http://jira.codehaus.org/browse/JRUBY-921
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.0.0
            Reporter: Bill Dortch


Subclasses of interface-only Java proxy classes don't inherit correctly. Note 
that this issue differs from JRUBY-910, which applies to  subclasses of 
concrete Java classes.

The following will not work:
{code}
class InterfacesOnly   # not descended/derived from the Java class hierarchy
  include java.lang.Runnable
  def run
  end
end
SomeClass.new.addRunnable InterfacesOnly.new #=> works

class IO2 < InterfacesOnly
  include java.lang.Comparable
  def compareTo(other)
    ...
  end
end
SomeClass.new.addRunnable IO2.new #=> fails
{code}

As I noted in JRUBY-910, interface-only classes reside in a nether-world; they 
are not descended from the Rubified Java hierarchy (there is no implicit 
java.lang.Object superclass, and really not a clean way to make this so once 
the user has declared the class).  They'll never really quite fit; 
kind_of?java.lang.Object will always respond false.

Nonetheless, it should be possible to make the above example work.  However, 
until then there is a simple workaround (contingent on the application of the 
patch for JRUBY-910):
{code}
class InterfacesOnly  < java.lang.Object
  include java.lang.Runnable
  def run
  ...
  end
end
SomeClass.new.addRunnable InterfacesOnly.new #=> works

class IO2 < InterfacesOnly
  include java.lang.Comparable
  def compareTo(other)
    ...
  end
end
SomeClass.new.addRunnable IO2.new #=> works
SomeClass.new.addComparable IO2.new #=> works
{code}

Because the workaround is so simple, I'd consider this low-priority for the 
moment.

-Bill

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

    http://xircles.codehaus.org/manage_email

Reply via email to