JDK-4339918 : getListeners() returns incorrect value
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: linux
  • CPU: x86
  • Submitted: 2000-05-22
  • Updated: 2000-05-22
  • Resolved: 2000-05-22
Related Reports
Duplicate :  
Relates :  
Description

Name: skR10017			Date: 05/22/2000



Java 2 Platform SE v1.3 Specification reads:

public EventListener[] getListeners(Class listenerType)

      Return an array of all the listeners that were added to the Component with addXXXListener(), where XXX is
      the name of the listenerType argument. For example, to get all of the MouseListeners for the given
      Component c, one would write: 

       MouseListener[] mls = (MouseListener[])(c.getListeners(MouseListener.class))
       

      If no such listener list exists, then an empty array is returned.
      Parameters:
            listenerType - Type of listeners requested
-----------------------------------------------------------------------------
The following test creates a class which implements PropertyChangeListener
and adds it to java.awt.Label component as PropertyChangeListener.
After that java.awt.Label.getListeners(PropertyChangeListener.class)
should return 1 but if executed under 

Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b05)
Java HotSpot(TM) Client VM (build 1.3.0beta-b03, mixed mode)
(Linux platform)
or under
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0rc3-Z)
Java HotSpot(TM) Client VM (build 1.3.0rc3-Z, interpreted mode)
(Solaris platform)

it returns 0.

BeanCounter test from Swing testsuite fails due to the same reason.

---------------------------test.java-------------------------------
import java.awt.Label;
import java.beans.*;
import java.util.EventListener;

public class test implements PropertyChangeListener
{
    public static void main(String [] args)
    {
        test t=new test();
        Label l=new Label();
        l.addPropertyChangeListener(t);
        EventListener[] listeners = l.getListeners(PropertyChangeListener.class);
        System.out.println("Listeners="+listeners.length);
    }
    public void propertyChange(PropertyChangeEvent evt) {}
}
------------------------output----------------------------------
[kotl@linux-5 BeanCounter]$ java test
Listeners=0
[kotl@linux-5 BeanCounter]$
----------------------------------------------------------------

======================================================================

Comments
EVALUATION This issue is not specific to Linux. It is described in 4290704. eric.hawkes@eng 2000-05-22
22-05-2000