[OpenJDK 2D-Dev] [9] RFR: JDK-8066139, , Null return from PrintJob.getGraphics() running closed/java/awt/PrintJob/HighResTest/HighResTest.java
prasanta sadhukhan
prasanta.sadhukhan at oracle.com
Fri Feb 19 09:18:41 UTC 2016
Hi Phil, All,
Bug: https://bugs.openjdk.java.net/browse/JDK-8066139
webrev: http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.00/
It was seen after fix of JDK-8061267
<https://bugs.openjdk.java.net/browse/JDK-8061267>: PrinterJob:
Specified Page Ranges not displayed in Windows Native Print Dialog
the closed/java/awt/PrintJob/HighResTest/HighResTest.java was failing
with NPE when PrinterJob.getGraphics() is called the 2nd time before
calling PrinterJob.end().
The above fix caused this regression because it sets the PD_PAGENUMS
flag for windows PrintDlg struct which causes *Pages* radio button to be
selected in print dialog.
However, fromPage and toPage was both set to 1 so after the 1st page is
printed, RasterPrinterJob.print(attributes) finishes and
graphicsToBeDrawn.closeWhenEmpty() gets called
http://hg.openjdk.java.net/jdk9/client/jdk/file/d8def65c6c00/src/java.desktop/share/classes/sun/print/PrintJob2D.java#l1006
which sets the queue to null so when PrinterJob2D#getGraphics() calls
graphicsToBeDrawn.pop() it sees queue to be null and sets graphics
object to be null so
PrinterJob.getGraphics() gets null and g.drawLine in testcase causes NPE
since g is null.
Fix was done to set the PD_PAGENUMS flag only when toPage is more than
fromPage in which case, "All" will be selected in printer dialog and
RasterPrinterJob.print() will finish only after printing all the pages.
Regards
Prasanta
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/2d-dev/attachments/20160219/671c7a48/attachment.html>
More information about the 2d-dev
mailing list