Bug 531 - get*Listeners methods from GLWindow throw ClassCast exceptions
Summary: get*Listeners methods from GLWindow throw ClassCast exceptions
Status: RESOLVED FIXED
Alias: None
Product: Newt
Classification: JogAmp
Component: core (show other bugs)
Version: 1
Hardware: All all
: --- normal
Assignee: Sven Gothel
URL:
Depends on:
Blocks:
 
Reported: 2011-12-02 11:39 CET by Sebastien Schneider
Modified: 2011-12-18 17:11 CET (History)
3 users (show)

See Also:
Type: ---
SCM Refs:
jogl 927521af10162f2bf8c02b12cce75bd7de71dafe
Workaround: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien Schneider 2011-12-02 11:39:04 CET
When I call getMouseListeners or getWindowListeners or getKeyListeners ... on a NEWT GLWindow I get a java ClassCastException that says that a Java Object array cannot be cast to a NEWT Listener array:
[Ljava.lang.Object; cannot be cast to [Lcom.jogamp.newt.event.MouseListener; in the case of the GLWindow.getMouseListeners()
Comment 1 Sebastien Schneider 2011-12-02 11:42:28 CET
change JOGL product to NEWT product
Comment 2 Julien Gouesse 2011-12-15 21:21:20 CET
Hi

For example, getWindowListeners() should not use toArray() because it returns Object[] instead of WindowListener[].

This method:
public WindowListener[] getWindowListeners() {
    return (WindowListener[]) windowListeners.toArray();
}

should be replaced by this one:
public WindowListener[] getWindowListeners() {
    return windowListeners.toArray(new WindowListener[windowListeners.size]);
}

There is the same bug with getKeyListeners(). If you don't want to use <T> T[] toArray(T[] a), just use a simple loop. Best regards.
Comment 3 Sven Gothel 2011-12-18 17:11:28 CET
fixed - thx.