JDK-6361766 : REG: Application does not exit after printing through a native print dialog, WinXP
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-12-10
  • Updated: 2010-05-11
  • Resolved: 2006-01-09
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 b67Fixed
Related Reports
Duplicate :  
Relates :  
Description
I am opening a native print dialog by calling PrinterJob.printDialog() and clicking on the 'print' button. Once the print data is printed, I expect the application to terminate (there is no code after the print() call) but the application is not terminating. It just waits there for ever. This happens regardless of whether I print the contents or cancel the dialog.

This is reproducible on WinXP only on Mustang. This is not reproducible with Mustang-b51 but reproducible on Mustang-b53. Hence this is a regression introduced in either b52 or b53. 

I have attached a sample test. Execute the sample test. You would see a native print dialog on the screen. Press 'ESC'. The native dialog gets disposed. Check whether the application has terminated. If not, the bug is reproduced. 

Here is the thread dump:
-------------------------
Full thread dump Java HotSpot(TM) Client VM (1.6.0-rc-b61 mixed mode):

"DestroyJavaVM" prio=6 tid=0x00036400 nid=0x127e0 waiting on condition [0x000000
00..0x008ffd4c]
   java.lang.Thread.State: RUNNABLE

"AWT-EventQueue-0" prio=6 tid=0x0ae2b600 nid=0x11724 in Object.wait() [0x0b6bf00
0..0x0b6bfd14]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02e85ff0> (a java.awt.EventQueue)
        at java.lang.Object.wait(Object.java:484)
        at java.awt.EventQueue.getNextEvent(EventQueue.java:480)
        - locked <0x02e85ff0> (a java.awt.EventQueue)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:245)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

"Thread-2" daemon prio=6 tid=0x0ae2a600 nid=0x127f8 runnable [0x0b5ef000..0x0b5e
fa14]
   java.lang.Thread.State: RUNNABLE
        at sun.print.Win32PrintServiceLookup.notifyPrinterChange(Native Method)
        at sun.print.Win32PrintServiceLookup.access$100(Win32PrintServiceLookup.
java:32)
        at sun.print.Win32PrintServiceLookup$PrinterChangeListener.run(Win32Prin
tServiceLookup.java:302)

"AWT-Windows" daemon prio=6 tid=0x0ade5000 nid=0x1215c runnable [0x0b07f000..0x0
b07fa94]
   java.lang.Thread.State: RUNNABLE
        at sun.awt.windows.WToolkit.eventLoop(Native Method)
        at sun.awt.windows.WToolkit.run(WToolkit.java:290)
        at java.lang.Thread.run(Thread.java:626)

"AWT-Shutdown" prio=6 tid=0x0ade1500 nid=0x401c in Object.wait() [0x0b02f000..0x
0b02fb14]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02a10510> (a java.lang.Object)
        at java.lang.Object.wait(Object.java:484)
        at sun.awt.AWTAutoShutdown.run(AWTAutoShutdown.java:259)
        - locked <0x02a10510> (a java.lang.Object)
        at java.lang.Thread.run(Thread.java:626)

"Java2D Disposer" daemon prio=10 tid=0x0adde500 nid=0x6440 in Object.wait() [0x0
afdf000..0x0afdfb94]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02a105a8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0x02a105a8> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at sun.java2d.Disposer.run(Disposer.java:123)
        at java.lang.Thread.run(Thread.java:626)

"Low Memory Detector" daemon prio=6 tid=0x0aaf6100 nid=0x12420 runnable [0x00000
000..0x00000000]
   java.lang.Thread.State: RUNNABLE

"CompilerThread0" daemon prio=10 tid=0x0aaf3b00 nid=0x11f28 waiting on condition
 [0x00000000..0x0acdf764]
   java.lang.Thread.State: RUNNABLE

"Attach Listener" daemon prio=10 tid=0x0aaf2c00 nid=0x11bc0 runnable [0x00000000
..0x00000000]
   java.lang.Thread.State: RUNNABLE

"Signal Dispatcher" daemon prio=10 tid=0x0aaf2100 nid=0x11900 waiting on conditi
on [0x00000000..0x00000000]
   java.lang.Thread.State: RUNNABLE

"Finalizer" daemon prio=8 tid=0x0aae5f00 nid=0x5b20 in Object.wait() [0x0abef000
..0x0abefa94]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02a10800> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:116)
        - locked <0x02a10800> (a java.lang.ref.ReferenceQueue$Lock)
        at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:132)
        at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:159)

"Reference Handler" daemon prio=10 tid=0x0aae1d00 nid=0x127f0 in Object.wait() [
0x0ab9f000..0x0ab9fb14]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x02a10890> (a java.lang.ref.Reference$Lock)
        at java.lang.Object.wait(Object.java:484)
        at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:116)
        - locked <0x02a10890> (a java.lang.ref.Reference$Lock)

"VM Thread" prio=10 tid=0x0aadee00 nid=0x107c runnable

"VM Periodic Task Thread" prio=10 tid=0x0aaf7400 nid=0x44f0 waiting on condition


JNI global references: 652

Comments
SUGGESTED FIX Dispose the native dialog after it was shown, somewhere in WPrinterJob.displayNativeDialog(). For example: --- WPrinterJob.java 2005-12-15 12:37:34.000000000 +0300 *************** *** 434,439 **** --- 434,440 ---- dialog.setRetVal(false); dialog.setVisible(true); boolean prv = dialog.getRetVal(); + dialog.dispose(); Destination dest = (Destination)attributes.get(Destination.class); The same should be done for page dialogs.
15-12-2005

EVALUATION New AWT modality implementation in Mustang has nothing in common with this CR. Cause of the problem is the following. Before the fix for 6302514 the code in WPrinterJob.printDialog() was: ... dialogOwner = new Frame(); ... boolean ret = displayNativeDialog(); dialogOwner.dispose(); ... As the native dialog was a child of dialogOwner, it was disposed after the native dialog was hidden. After the fix the behaviour is changed. Now we don't create dialogOwner, but simply call to disposeNativeDialog(). As a result, native dialog is not disposed and application doesn't exit. Moreover, I suspect that the same bug exist with page dialogs. I'm reassiging this CR back to 2D team as WPrinterJob is more 2D than AWT.
15-12-2005

EVALUATION This started in b53 due to fix for 6302514:XToolkit: Toolkit modal dialog getting blocked by Page/Print dialog. The fix made is to pass a null parent to the print dialog. This looks like a bug in the implementation of new modality APIs. Assigning to AWT.
13-12-2005