Nested Interfaces can't find the correct method when Java calls Ruby
--------------------------------------------------------------------

                 Key: JRUBY-2863
                 URL: http://jira.codehaus.org/browse/JRUBY-2863
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.1.4
            Reporter: Logan Barnett


----The Java code----
import java.awt.event.ActionListener;

public class TestFrame extends javax.swing.JFrame
{
        // historically, a long chain of listeners went here
        public interface RubyEventHandler extends ActionListener
        {
                
        }
        
        RubyEventHandler handler;
        javax.swing.JCheckBoxMenuItem check_box_item;
        public TestFrame(RubyEventHandler handlerInstance)
        {
                javax.swing.JMenuBar menuBar = new javax.swing.JMenuBar();
                check_box_item = new javax.swing.JCheckBoxMenuItem();
                menuBar.add(check_box_item);
                handler = handlerInstance;
                check_box_item.addActionListener(handler);
                check_box_item.setText("Check Me");
                setJMenuBar(menuBar);
        }
}

-----The Ruby code-----
class TestFrame
  include Java::TestFrame::RubyEventHandler

  def initialize
    @view = Java::TestFrame.new(self)
    @view.visible = true
  end
  
  def actionPerformed(event)
    puts "something was clicked"
  end
end

TestFrame.new

---- The error when clicking -----
Exception in thread "AWT-EventQueue-0" java.lang.AbstractMethodError: 
InterfaceImpl352.actionPerformed(Ljava/awt/event/ActionEvent;)V
        at 
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
        at 
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2202)
        at 
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
        at 
javax.swing.JToggleButton$ToggleButtonModel.setPressed(JToggleButton.java:269)
        at javax.swing.AbstractButton.doClick(AbstractButton.java:334)
        at 
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1051)
        at apple.laf.CUIAquaMenuItem.doClick(CUIAquaMenuItem.java:119)
        at 
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1092)
        at java.awt.Component.processMouseEvent(Component.java:5602)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
        at java.awt.Component.processEvent(Component.java:5367)
        at java.awt.Container.processEvent(Container.java:2010)
        at java.awt.Component.dispatchEventImpl(Component.java:4068)
        at java.awt.Container.dispatchEventImpl(Container.java:2068)
        at java.awt.Component.dispatchEvent(Component.java:3903)
        at 
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
        at java.awt.Container.dispatchEventImpl(Container.java:2054)
        at java.awt.Window.dispatchEventImpl(Window.java:1791)
        at java.awt.Component.dispatchEvent(Component.java:3903)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
        at 
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
        at 
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

---- notes ----
Subsituting RubyEventHandler with ActionListener (the interface it inherits 
from) makes this code work. This must be done both in Ruby and in Java.


-- 
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