United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6813208 pageDialog throws NPE from applet
JDK-6813208 : pageDialog throws NPE from applet

Details
Type:
Bug
Submit Date:
2009-03-04
Status:
Closed
Updated Date:
2010-12-25
Project Name:
JDK
Resolved Date:
2009-08-10
Component:
client-libs
OS:
windows_vista
Sub-Component:
java.awt
CPU:
x86
Priority:
P2
Resolution:
Fixed
Affected Versions:
6u12
Fixed Versions:
6u16-rev (b02)

Related Reports
Backport:
Backport:
Relates:

Sub Tasks

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

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).
                                     
2009-06-11
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
                                     
2009-06-11
EVALUATION

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



Hardware and Software, Engineered to Work Together