On Sun, 1 Mar 2026 18:38:39 GMT, Phil Race <[email protected]> wrote:

>>> I wonder if this is right ? Surely if the PageRanges is not there any more, 
>>> we should update the JobAttributes to a default range ? This would leave 
>>> whatever stale value is present.
>> 
>> Since null check is being frowned upon, I have modified 
>> [JDK-8373239](https://bugs.openjdk.org/browse/JDK-8373239) fix to not remove 
>> PageRanges attribute and set it to default value incase native code doesn't 
>> set `isRangeSet` parameter via JNI.
>> 
>> The default value of PageRanges according to spec  
>> https://docs.oracle.com/en/java/javase/25/docs/api/java.desktop/javax/print/attribute/standard/PageRanges.html
>> 
>> `In other words, the default value for the PageRanges attribute is always 
>> {{1, Integer.MAX_VALUE}}. ` 
>> 
>> and having Pageable.UNKNOWN_NUMBER_OF_PAGES will cause 
>> IllegalArgumentException 
>> https://github.com/openjdk/jdk/blob/f25d429c8d6d099666aefd698ed14628cce5b1cf/src/java.desktop/share/classes/javax/print/attribute/standard/PageRanges.java#L193-L194
>> 
>> 
>> but kept setPageRanges value same as Pageable.UNKNOWN_NUMBER_OF_PAGES to 
>> honour its spec
>> 
>> https://github.com/openjdk/jdk/blob/f25d429c8d6d099666aefd698ed14628cce5b1cf/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java#L1847-L1858
>> 
>> Regarding test, since the problem is reproduced in 1.1 PrintJob by just 
>> selecting "ALL" in print dialog, which is the default selection, [and there 
>> is no need to verify actual print output] and since ScaledImagePrinting test 
>> uses default printdialog settings, it will reproduce the issue and it will 
>> also avoid another new manual printing test
>
> So the previous fix basically completely broke 1.1 API printing on Windows ...

> since we now always initialize the PageRange guess it will never be null and 
> it has ran without that check since 1.1 so I guess we are ok.

I agree with [Prasanta's 
evaluation](https://github.com/openjdk/jdk/pull/29874/changes#r2887458409), 
that code has been running since 1.1 and hasn't caused any issues. Now that the 
code in `WPrinterJob.java` is reverted to the state is was before 
[JDK-8373239](https://bugs.openjdk.org/browse/JDK-8373239) which ensures the 
`PageRanges` attribute is always present, the null-check becomes redundant as 
the condition `range != null` is always `true`.

Therefore, I'm for removing the null-check.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2889362143

Reply via email to