JDK-4256840 : Exception when using the no-argument Window() constructor on win32
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_2.6
  • CPU: x86
  • Submitted: 1999-07-23
  • Updated: 1999-08-26
  • Resolved: 1999-08-26
Related Reports
Relates :  
Description
The following, simple test program of the new no-argument Window() constructor
fails with an exception on Windows (it was either Windows 95 or 98--I didn't
try it on NT).  It works fine on Solaris.

    java -version
    java version "1.3"
    HotSpot Client VM (1.3beta, mixed mode, build l)

    java WindowTest
    Exception in thread "main" java.lang.NullPointerException: peer
        at sun.awt.windows.WWindowPeer.createAwtWindow(Native Method)
        at sun.awt.windows.WWindowPeer.create(WWindowPeer.java:112)
        at sun.awt.windows.WComponentPeer.<init>(WComponentPeer.java:324)
        at sun.awt.windows.WCanvasPeer.<init>(WCanvasPeer.java:30)
        at sun.awt.windows.WPanelPeer.<init>(WPanelPeer.java:69)
        at sun.awt.windows.WWindowPeer.<init>(WWindowPeer.java:90)
        at sun.awt.windows.WToolkit.createWindow(WToolkit.java:221)
        at java.awt.Window.addNotify(Window.java:304)
        at java.awt.Window.show(Window.java:343)
        at java.awt.Component.show(Component.java:917)
        at java.awt.Component.setVisible(Component.java:875)
        at WindowTest.main(WindowTest.java:9)

If you change the "new Window()" call to "new Window(new Frame())" it
works.

---------------------------------------------------------------------------
import java.awt.*;

public class WindowTest {
    public static void main(String[] args) {
        Window w = new Window();

        w.setLocation(100, 100);
        w.setSize(200, 200);
        w.setVisible(true);
    }
}
---------------------------------------------------------------------------


Comments
WORK AROUND Use "new Window(new Frame())" instead of "new Window()"
11-06-2004

EVALUATION Commit to fix in Kestrel. eric.hawkes@eng 1999-07-24 Note from dpm: Andy Herrick noted that there is probably an issue with this constructor on Solaris under olwm. Specifically, he suspects that the Window will appear with decorations because it won't be properly set to override-redirect. So before you putback a fix for this bug, could you test on olwm as well? Dave also notes that there will likely be a problem with getOwnedWindows(). brent.christian@eng 1999-08-05 Actually, the issue is that Windows created with the Window() constructor won't and should not show up in the array returned from Frame.getFrames(). The Window() constructor introduces the problem of no longer being able to get all top-level Windows(). It looks a getWindows() call should be added to java.awt.Window. But that's a different bug... brent.christian@eng 1999-08-05 This issue has been sidestepped completely with the advent of RFE 4262946: API Change: remove constructors for ownerless Windows in java.awt.Window. The no-argument Window() constructor is no longer a part of the public API. brent.christian@eng 1999-08-25
25-08-1999