public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
From: "gruni dot ca at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: java-prs@gcc.gnu.org
Subject: [Bug java/21065] New: javax.swing.event.EventListenerList.getListenerList() implemented wrong
Date: Sun, 17 Apr 2005 00:11:00 -0000	[thread overview]
Message-ID: <20050417001142.21065.gruni.ca@gmail.com> (raw)

I am using a custom Class wich throws events, by using this I rely on the
EventListenerList Class to hold my Eventlisteners. The Method getListenerList is
used by the method 

 protected void fireFooXXX() {
    // Guaranteed to return a non-null array
    Object[] listeners = listenerList.getListenerList();
    // Process the listeners last to first, notifying
    // those that are interested in this event
    for (int i = listeners.length-2; i>=0; i-=2) {
        if (listeners[i]==FooListener.class) {
            // Lazily create the event:
            if (fooEvent == null)
                fooEvent = new FooEvent(this);
            ((FooListener)listeners[i+1]).fooXXX(fooEvent);
        }
    }
}

which is the standard Method given in the API to fire Events to all
EventListeners. This Method relies on the correct implementation of
getListenerList() which should according to the API Documentation of Java by SUN
http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/event/EventListenerList.html#getListenerList()
[quote]
getListenerList

public Object[] getListenerList()

    Passes back the event listener list as an array of ListenerType-listener
pairs. Note that for performance reasons, this implementation passes back the
actual data structure in which the listener data is stored internally! This
method is guaranteed to pass back a non-null array, so that no null-checking is
required in fire methods. A zero-length array of Object should be returned if
there are currently no listeners. WARNING!!! Absolutely NO modification of the
data contained in this array should be made -- if any such manipulation is
necessary, it should be done on a copy of the array returned rather than the
array itself.
[/quote]

The API doc says "Passes back the event listener list as an array of
ListenerType-listener pairs." my understanding of pairs is multiples of two, so
the EventListenerList can never contain 1 or 3 entries or any other odd number.
But when adding one Eventlistener to such a list it really just adds this
EventListener resulting in a getListenerList() which returns one Element, which
is simply wrong.

A Testcase will follow as soon as I have written one.

btw this is my system: WinXP SP2
                       gcj 4.0 20050324 from thisiscool.com

Regards,

Andreas

-- 
           Summary: javax.swing.event.EventListenerList.getListenerList()
                    implemented wrong
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: critical
          Priority: P1
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gruni dot ca at gmail dot com
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21065


             reply	other threads:[~2005-04-17  0:11 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-17  0:11 gruni dot ca at gmail dot com [this message]
2005-04-17  0:46 ` [Bug java/21065] " gruni dot ca at gmail dot com
2005-04-17  0:57 ` gruni dot ca at gmail dot com
2005-04-23 15:51 ` [Bug libgcj/21065] " rmathew at gcc dot gnu dot org
2005-04-23 15:53 ` [Bug SWING/21065] " pinskia at gcc dot gnu dot org
2005-04-25  8:57 ` roman at kennke dot org
2005-04-25  9:50 ` konqueror at gmx dot de
2005-04-26 20:23 ` tromey at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050417001142.21065.gruni.ca@gmail.com \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=java-prs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).