JDK-6469440 : Regression: Encounter NPE when trying to print a help topic provided by JavaHelp
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P1
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2006-09-11
  • Updated: 2007-10-16
  • Resolved: 2006-09-27
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6
6 b100Fixed
Related Reports
Relates :  
Relates :  
Description
Visual Web Pack Build 060905_7 (or the latest) w/ NetBeans Build 20060908
WinXP
JDK 1.6.0-rc-b98

Steps to reproduce:
1. Using Visual Web Pack installation instructions in the README at this location http://clue.sfbay/kits/rave/main/latest/pack_installers;  All the binaries needed for installation are under this location (e.g. NetBeans, Visual Web Pack and GlassFish, etc).  However for this particular scenario, you don't need to install GlassFish.
2. Start Netbeans: $installDir\bin\netbeans
3. Create a Web project with "Visual Web Application" category and select J2EE 1.4 as the J2EE project type
4. After the project is open, click on Dynamic Help tab window on the right hand side
5. select any topic  to bring up the JavaHelp viewer and press print icon in the JavaHelp viewer window
6. ok print dialog for installed printer OK

>>get UnexpectedException Dialog (see NPE below) but OK will not dismiss the

 dialog, nor will Show details button work. CAnnot dismiss dialog or close down IDE.
 Need to kill IDE via taskmgr.

 
  From the log:

java.lang.NullPointerException
        at java.awt.Window.updateChildFocusableWindowState(Window.java:858)
        at java.awt.Window.show(Window.java:844)
        at java.awt.Component.show(Component.java:1419)
        at java.awt.Component.setVisible(Component.java:1372)
        at java.awt.Window.setVisible(Window.java:801)
        at com.sun.java.help.impl.JHelpPrintHandler$JHPrintable.createTransforms(JHelpPrintHandler.java:566)
        at com.sun.java.help.impl.JHelpPrintHandler$JHPrintable.getNumberOfPages(JHelpPrintHandler.java:535)
        at com.sun.java.help.impl.JHelpPrintHandler$JHPageable.getNumberOfPages(JHelpPrintHandler.java:891)
        at sun.awt.windows.WPrinterJob.getMaxPageAttrib(WPrinterJob.java:1532)
        at sun.awt.windows.WPrinterJob.getToPageAttrib(WPrinterJob.java:1507)
        at sun.awt.windows.WPrintDialogPeer._show(Native Method)
        at sun.awt.windows.WPrintDialogPeer.access$000(WPrintDialogPeer.java:16)
        at sun.awt.windows.WPrintDialogPeer$1.run(WPrintDialogPeer.java:48)
[catch] at java.lang.Thread.run(Thread.java:619)

*** (#1 of 2): 2006-09-06 02:29:21 GMT+00:00	###@###.###
*** Last Edit: 2006-09-06 02:29:21 GMT+00:00	###@###.###

Switched jdk in /etc/netbeans.conf to jdk1.5.0_07 and printing
worked ok. Switching back to jdk1.6.0, got the same hang, so confirming:
this is related to Mustang JDK.

*** (#2 of 2): 2006-09-06 02:51:10 GMT+00:00	###@###.###
*** Last Edit: 2006-09-06 02:51:10 GMT+00:00	###@###.###

Comments
EVALUATION JavaHelp Print handler is purposely not creating a peer so the window doesn't show up on the screen. This is absolutely essential to be able to achieve multipage printing in the help system. In order for the printing to perform correctly the JEditorPane has to be realized creating the proper sizes and layout. Creating a peer would cause the window to be displayed on the screen which is a undesireable user experience. Implementing the change that AWT has suggested will cause a complete rewrite of the JavaHelpPrinting code. This will additionally cause a lack of functionality with reqards to the ability to print multiply selected pages. While I understand the need to set the FocasableWindowState a simple check to see if the peer is null before performing the action is a reasonable and low risk change. In that particular case if there is no peer you wouldn't want to the set the focus anyway. Transfering back to AWT for the one line change to made there.
22-09-2006

EVALUATION Reassigning to java help team.
13-09-2006

EVALUATION well, the problem is in Java Help's implementation. See com.sun.java.help.impl.JHelpPrintHelper. For printing support it creates a custom frame (JHFrame from the same file) amd this frame overrides addNotif(). public void addNotify() { getRootPane().addNotify(); } Note it doesn't create peer for the frame itself. Later in JHPrintable.createTransforms() we call addNotify() an setVisible(true) on this frame. In Window.show() we (AWT) call updateChildFocusableWindowState() which just check isShowing() and call method on frame's peer. From AWT point of view (isShowng() == true) must guaratee that toplevel has a peer. So, AWT code is correct, and it is JHFrame that violates Frame's contract and should be corrected.
13-09-2006

EVALUATION According to the stack trace NPE occurs at the code if (w.isShowing()) { --> here ((WindowPeer)w.getPeer()).updateFocusableWindowState(); } It seems that at the moment of this call window's peer is null while isShowing() returns true. I have noticed that in Component class isShowing() returns true only if component's peer is not null, but in Window class this method is overridden and doesn't include the check (peer != null). Another note is that in several other places in AWT code there are checks isShowing() followed by (peer != null), so at this place the same additional check should be probably added. *** (#1 of 1): [ UNSAVED ] ###@###.###
12-09-2006

EVALUATION Actually if toplevel is visible it must have a peer, since we do create it in the first line of show(). So, the condition is correct. It looks like Java Help or someone else breaks AWT internals :( need to check JH sources.
12-09-2006