[Bug java/21065] New: javax.swing.event.EventListenerList.getListenerList() implemented wrong
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
[Bug java/21065] javax.swing.event.EventListenerList.getListenerList() implemented wrong
--- Additional Comments From gruni dot ca at gmail dot com 2005-04-17 00:45 --- Created an attachment (id=8663) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8663&action=view) Simple Testcase showing that addind a EventListener increments the list by one This is a testcase I wrote, I compiled it with gcj --main=GcjEventListenerListTest -o EventTest.exe GcjEventListenerListTest.java the output should be similar to JDK if implemented correctly JDK output: should be=2 is=2 should be=4 is=4 GCJ output: should be=2 is=1 should be=4 is=2 That's all I have -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21065
[Bug java/21065] javax.swing.event.EventListenerList.getListenerList() implemented wrong
-- What|Removed |Added Attachment #8663|Simple Testcase showing that|Simple Testcase showing that description|addind a EventListener |adding a EventListener |increments the list by one |increments the list by one http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21065
[Bug java/21068] New: String(strBytes, "UTF-16LE"); thorws java.io.UnsupportedEncodingException
The constructor String(strBytes, "UTF-16LE"); throws a UnsupportedEncodingException which is not logical, becasue the Charset is supported according to Charset.availableCharsets() TestCase will follow. This is my output Available Charsets are: {ISO-8859-1=ISO-8859-1, US-ASCII=US-ASCII, UTF-16=UTF-16, UTF-16BE=UTF-16BE, UTF-16LE=UTF-16LE, UTF-8=UTF-8} Exception in thread "main" java.io.UnsupportedEncodingException: UTF-16LE (java.lang.ClassNotFoundException: gnu.gcj.con vert.Input_UnicodeLittle not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:.\], parent=gnu.gcj.runtime.VMClassLo ader{urls=[core:/], parent=null}}) at GcjStringTest.main(java.lang.String[]) (E:\2004-development\2005-extraextra\src\GcjStringTest.java) at ._main (C:\DOKUME~1\GRUNEW~1\LOKALE~1\Temp\ccM5baaa.i) And accoring to the APIdocs: String public String(byte[] bytes, String charsetName) throws UnsupportedEncodingException Constructs a new String by decoding the specified array of bytes using the specified charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array. The behavior of this constructor when the given bytes are not valid in the given charset is unspecified. The CharsetDecoder class should be used when more control over the decoding process is required. Parameters: bytes - the bytes to be decoded into characters charsetName - the name of a supported charset Throws: UnsupportedEncodingException - If the named charset is not supported Since: JDK1.1 The charset should be taken out of the Charsets class. So ya this is a bug in my eyes. Regards, Andreas -- Summary: String(strBytes, "UTF-16LE"); thorws java.io.UnsupportedEncodingException Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: critical Priority: P2 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=21068
[Bug java/21068] String(strBytes, "UTF-16LE"); thorws java.io.UnsupportedEncodingException
--- Additional Comments From gruni dot ca at gmail dot com 2005-04-17 12:43 --- Created an attachment (id=8665) --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=8665&action=view) Tests the String(strBytes, "UTF-16LE"); which shouldn't return an Exception This is the testcase which runs without Exception in JDK but throws the UnsupportedEncodingException when compiled with GCJ. My system was WinXP with GCJ 4.0 from thisiscool.com Hope someone can verify this bug. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21068
[Bug libgcj/21068] String(strBytes, "UTF-16LE"); thorws java.io.UnsupportedEncodingException
--- Additional Comments From gruni dot ca at gmail dot com 2005-04-17 17:27 --- Allright that solved this problem. Unfortunately I can not run the programm anymore in JDK after adding the static. Is there a way to keep my sources compatible with JDK and GCJ ? Regrads Andreas -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21068