JDK-6813208 : pageDialog throws NPE from applet
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6u12
  • Priority: P2
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_vista
  • CPU: x86
  • Submitted: 2009-03-04
  • Updated: 2010-12-25
  • Resolved: 2009-08-10
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 JDK 7
6u16-rev b02Fixed 7Fixed
Related Reports
Relates :  
Description
The customer reports a problem with the following code.

aPrinterJob = java.awt.print.PrinterJob.getPrinterJob();
aPrinterJob.pageDialog(new PageFormat()); 

They submitted a testcase of a small applet to reproduce the problem. The testcase is attached.

But the exception does not come all the time. You may have to reload the applet and click again on the OK button to see the exception in the java console. A dialog with an OK button will appear. When you click on the OK button, the following exception appears 3 time in the java console.

Exception occurred during event dispatching:

java.lang.NullPointerException: null pData
at sun.awt.windows.WComponentPeer._requestFocus(Native Method)
at sun.awt.windows.WComponentPeer.requestFocus(Unknown Source)
at java.awt.Component.requestFocusHelper(Unknown Source)
at java.awt.Component.requestFocusHelper(Unknown Source)
at java.awt.Component.requestFocus(Unknown Source)
at sun.plugin2.main.client.PluginMain$2.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

This looked similar to CR 6707276, which was reported as no longer reproducible using 6u12 b03 nightly build. I asked the customer to use 6u12 b04. They were able to see the problem with 6u12 b04. The issue is reproducible on Windows XP SP2 and Windows Vista SP1.

The customer is not satisfied with the work-around of disabling plugin2, due to the large number of users and systems using this applet. They requested this bug be fixed.

Comments
EVALUATION http://hg.openjdk.java.net/jdk7/build/jdk/rev/ad7feec4413e
25-12-2010

SUGGESTED FIX The fix would be to make sure _requestFocus() is not called from WPrintDialogPeer.java or from WFileDialogPeer by overriding requestFocus() method in those classes. After such overwrite method: public boolean requestFocus(Component lightweightChild, boolean temporary, boolean focusedWindowChangeAllowed, long time, CausedFocusEvent.Cause cause); originally defined in sun.awt.windows.WComponentPeer.java will not be called for WPrintDialogPeer.java and for from WFileDialogPeer.java
11-06-2009

EVALUATION In case of requesting focus from WPrintDialogPeer.java or from WFileDialogPeer focus is requested to some disposed component so that's why we are getting NPE in sun.awt.windows.WComponentPeer._requestFocus(Native Method).
11-06-2009