<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hi Jay,<br>
<br>
Updated testcase<br>
<a class="moz-txt-link-freetext" href="http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.03/">http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.03/</a><br>
<br>
Regards<br>
Prasanta<br>
<div class="moz-cite-prefix">On 3/16/2016 12:58 PM, Jayathirth D V
wrote:<br>
</div>
<blockquote cite="mid:aeb4e97e-8ba1-4623-8986-a4328c768bf8@default"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">HI
Prasanta,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Changes
are fine. Both the print dialogs are coming and there is no
NPE. <o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">In
test case please change copyright year to 2016 and also it
is better to have jtreg comments before import statements
for readability. <o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Jay<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1
1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">From:</span></b><span
style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">
Phil Race <br>
<b>Sent:</b> Wednesday, March 16, 2016 3:45 AM<br>
<b>To:</b> prasanta sadhukhan<br>
<b>Cc:</b> <a class="moz-txt-link-abbreviated" href="mailto:2d-dev@openjdk.java.net">2d-dev@openjdk.java.net</a><br>
<b>Subject:</b> Re: [OpenJDK 2D-Dev] [9] RFR:
JDK-8066139, , Null return from PrintJob.getGraphics()
running
closed/java/awt/PrintJob/HighResTest/HighResTest.java<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 03/10/2016 02:34 AM, prasanta
sadhukhan wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Phil,<br>
<br>
Please find the modified webrev <br>
<a moz-do-not-send="true"
href="http://cr.openjdk.java.net/%7Epsadhukhan/8066139/webrev.02/">http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.02/</a><o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
+1<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
I tested in Mac too but there it seems to be working (ie no
NPE) without and with this fix.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
The mac code is sufficiently different that it is not a
surprise that it behaves differently.<br>
<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">For issue seen on windows , I have raised
a bug <a moz-do-not-send="true"
href="https://bugs.openjdk.java.net/browse/JDK-8151589"
id="key-val">JDK-8151589</a> (strangely it is not seen in
jdk1.8.0_76 but seen from 1.9.0-ea-b01 onwards, can you
tell me what is the release version before b01?]<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
That suggests a bug introduced before 8GA, fixed in an
8-update, but not in 9.<br>
But I find that a bit unlikely and I don't want to speculate
more. It just needs investigation.<br>
<br>
-phil.<br>
<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><br>
Regards<br>
Prasanta<o:p></o:p></p>
<div>
<p class="MsoNormal">On 3/8/2016 9:45 PM, Philip Race wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">> However, I am finding a strange
issue with and without this fix too. The "Center" string
is not printed<br>
<br>
Sounds completely unrelated to anything to do with the NPE
bug.<br>
<br>
It is probably appropriate to file that as a separate bug.<br>
No big surprise that the behaviour is platform-specific as
there<br>
is a lot of difference in Windows vs Linux (or vs Mac) in
the printing code.<br>
<br>
-phil.<br>
<br>
On 3/8/16, 2:30 AM, prasanta sadhukhan wrote: <o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On 3/8/2016 2:17 AM, Phil Race
wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">I don't think starting a new
thread can be right. That would re-invoke<br>
printerJob.print() which even if you can reuse a
PrinterJob (something that<br>
was never set out in spec.) you are surely getting a
new spool job .. not<br>
a continuation. There a couple of other things I am
not sure about either.<br>
<br>
I've looked into this - only on Linux - and I
believe the issue is that<br>
the test program has decided up-front how many pages
it is going to<br>
print and it is paying no attention to the selected
page ranges.<br>
Not what the 'user' asked for but it is perfectly
within its rights to do so.<br>
<br>
However the 2D PrinterJob operates in a way where it
calls back<br>
asking for the specific pages it wants to be printed
and there the<br>
app. must comply. The PrinterJob terminates once it
has done.<br>
<br>
In the case when the 2D PrinterJob is being used to
'run' a<br>
PrintJob then it must *never* return until the
application has<br>
called "end" - or some exception occurs.<br>
<br>
So we need to remove the elements that will cause
the job to exit.<br>
<br>
---
a/src/java.desktop/share/classes/sun/print/PrintJob2D.java<br>
+++
b/src/java.desktop/share/classes/sun/print/PrintJob2D.java<br>
@@ -995,6 +995,7 @@<br>
public void run() {<br>
<br>
try {<br>
+ attributes.remove(PageRanges.class);<br>
printerJob.print(attributes);<br>
} catch (PrinterException e) {<br>
//REMIND: need to store this away and
not rethrow it.<br>
diff --git
a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java
b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java<br>
---
a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java<br>
+++
b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java<br>
@@ -1172,6 +1172,7 @@<br>
pageRangesAttr =
(PageRanges)attributes.get(PageRanges.class);<br>
if (!isSupportedValue(pageRangesAttr,
attributes)) {<br>
pageRangesAttr = null;<br>
+ setPageRange(-1, -1);<br>
} else {<br>
if
((SunPageSelection)attributes.get(SunPageSelection.class)<br>
== SunPageSelection.RANGE) {<br>
<br>
<br>
This works for me on Linux although <br>
a) I have not tried Windows)<o:p></o:p></p>
</div>
</blockquote>
<p class="MsoNormal">I tried on windows. The NPE is not
seen and it prints 2 pages.<br>
However, I am finding a strange issue with and without
this fix too. The "Center" string is not printed in the
1st page in both "Portrait" and "Landscape" mode
(although the rectangles are printed) but is printed in
the 2nd page.<br>
I do not find this issue in linux.<br>
<br>
Regards<br>
Prasanta<br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">b) I have not verified if there
are no negative consequences from the 2nd change.<br>
<br>
-phil.<br>
<br>
On 03/01/2016 03:14 AM, prasanta sadhukhan wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Phil,<br>
<br>
Please find an updated webrev:<br>
<a moz-do-not-send="true"
href="http://cr.openjdk.java.net/%7Epsadhukhan/8066139/webrev.01/">http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.01/</a><br>
<br>
It seems if printerJobThread finished printing, it
will set graphicsToBeDrawn/graphicsDrawn ArrayList
to null resulting in getGraphics() returning null in
the 2nd iteration causing NPE so<br>
I have modified printerJobThread#run so that when
it has finished printing, do not set the arrayList
to null but set a flag. In getGraphics(), I check
that flag and start a new printerJobThread to handle
the next printing.<br>
I have tested "All" and "Pages" selection.<br>
<br>
Regards<br>
Prasanta<o:p></o:p></p>
<div>
<p class="MsoNormal">On 2/22/2016 1:35 PM, Philip
Race wrote:<o:p></o:p></p>
</div>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">> It seems this behaviour is
same in linux too for this HighResTest testcase.<br>
<br>
OK that is good information .. so is not really a
regression from <a moz-do-not-send="true"
href="https://bugs.openjdk.java.net/browse/JDK-8061267"
id="key-val">8061267</a> as that is not in<br>
any way touching linux .. it is a pre-existing
issue in a code path that was not being tested.<br>
<br>
-phil.<br>
<br>
On 2/22/16, 11:59 AM, prasanta sadhukhan wrote: <o:p></o:p></p>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Phil,<br>
<br>
>>Additionally, have you tried running the
original test case provided with 8061267<br>
>> against your fix ?<br>
The 8061267 testcase behaves similarly before
and after my fix.<br>
<br>
>> If I manually select it, (ie select
that "Pages" radio button) then press print,<br>
>> then voila, the NPE is back!<br>
It seems this behaviour is same in linux too for
this HighResTest testcase.<br>
<br>
Regards<br>
Prasanta<o:p></o:p></p>
<div>
<p class="MsoNormal">On 2/20/2016 1:55 AM, Phil
Race wrote:<o:p></o:p></p>
</div>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">I am having trouble
building JDK 9 at the moment so i applied
8061267 to jdk8u-dev<br>
and was able to reproduce the regression and
have a couple of observations<br>
<br>
- I am now seeing the NPE after the first
page as you did .. puzzling.<br>
- I next applied your fix but still see the
NPE !<br>
<br>
It appears that all your fix did is stop the
"PD_PAGENUMS" flag being automatically<br>
set. If I manually select it, (ie select
that "Pages" radio button) then press print,<br>
then voila, the NPE is back!<br>
<br>
-phil.<br>
<br>
<br>
On 02/19/2016 10:53 AM, Phil Race wrote:<o:p></o:p></p>
</div>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">I am not sure I can be
correctly understanding the fix as the
ramification seems<br>
to be that if the users wants to print
only Page 3 of a 10 page document and so
sets<br>
from page=3 and to page=3, that this
request will be ignored and all pages will<br>
be printed .. can you test such a
scenario.<br>
<br>
Additionally, have you tried running the
original test case provided with 8061267<br>
against your fix ?<br>
<br>
Also when I ran the HighResTest on a
current build I saw a null graphics on<br>
the very first call to getGraphics() which
is different than what I interpret<br>
you as saying - you see the null *after*
the first page is printed.<br>
<br>
-phil.<br>
<br>
On 02/19/2016 01:18 AM, prasanta sadhukhan
wrote:<o:p></o:p></p>
</div>
<blockquote
style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Phil, All,<br>
<br>
Bug: <a moz-do-not-send="true"
href="https://bugs.openjdk.java.net/browse/JDK-8066139">https://bugs.openjdk.java.net/browse/JDK-8066139</a><br>
webrev: <a moz-do-not-send="true"
href="http://cr.openjdk.java.net/%7Epsadhukhan/8066139/webrev.00/">http://cr.openjdk.java.net/~psadhukhan/8066139/webrev.00/</a><br>
<br>
It was seen after fix of <a
moz-do-not-send="true"
href="https://bugs.openjdk.java.net/browse/JDK-8061267"
id="key-val">JDK-8061267</a>:
PrinterJob: Specified Page Ranges not
displayed in Windows Native Print Dialog<br>
the
closed/java/awt/PrintJob/HighResTest/HighResTest.java
was failing with NPE when
PrinterJob.getGraphics() is called the 2nd
time before calling PrinterJob.end().<br>
<br>
The above fix caused this regression
because it sets the PD_PAGENUMS flag for
windows PrintDlg struct which causes <strong>Pages</strong>
radio button to be selected in print
dialog.<br>
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<br>
<a moz-do-not-send="true"
href="http://hg.openjdk.java.net/jdk9/client/jdk/file/d8def65c6c00/src/java.desktop/share/classes/sun/print/PrintJob2D.java#l1006">http://hg.openjdk.java.net/jdk9/client/jdk/file/d8def65c6c00/src/java.desktop/share/classes/sun/print/PrintJob2D.java#l1006</a><br>
<br>
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<br>
PrinterJob.getGraphics() gets null and
g.drawLine in testcase causes NPE since g
is null.<br>
<br>
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.<br>
<br>
Regards<br>
Prasanta<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</blockquote>
<br>
</body>
</html>