JDK-4268744 : java.awt.Window default constructor causes NullPointerExc (Reply to RevID 94817)
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.2.2
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_98
  • CPU: x86
  • Submitted: 1999-09-03
  • Updated: 1999-09-03
  • Resolved: 1999-09-03
Related Reports
Duplicate :  
Description

Name: skT88420			Date: 09/03/99


Review ID 94817 said my bug didn't work on Solaris. It's right,
and I'm wrong. It only produces a bug on Windows 98,
maybe 95 also, but I don't know.

====================== Incident ID #94817 ==================

java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)

java full version "1.3beta-O"


When you attempt to show a java.awt.Window constructed
using the empty constructor, it throws a NullPointerException.
By the way, is the output for errors being printed backwards?


import java.awt.*;
import java.awt.event.*;

public class asdf {
	public static void main (String[] args) {
		Window f = new Window();
		f.setSize(300,300);
        f.addWindowListener(new WindowAdapter() {
            public void windowIconified(WindowEvent e) {
                Window w = e.getWindow();
                w.toFront();
            }
        });
		f.setVisible(true);
	}
}

------Causes NullPointerException:
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:237)
        at java.awt.Window.addNotify(Window.java:304)
        at java.awt.Window.show(Window.java:343)
        at java.awt.Component.show(Component.java:922)
        at java.awt.Component.setVisible(Component.java:880)
        at asdf.main(asdf.java:18)
(Review ID: 94819) 
======================================================================