RFR: 8373239: Test java/awt/print/PrinterJob/PageRanges.java fails with incorrect selection of printed pages [v3]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Fri Jan 23 02:58:26 UTC 2026
On Thu, 22 Jan 2026 01:30:33 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:
>> src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java line 1737:
>>
>>> 1735: setPageRange(from, to);
>>> 1736: } else {
>>> 1737: attributes.remove(PageRanges.class);
>>
>> I'm a bit surprised you didn't need to still reset the page range ... is something else re-setting it ?
>> setPageRange(Pageable.UNKNOWN_NUMBER_OF_PAGES, Pageable.UNKNOWN_NUMBER_OF_PAGES)
>
> Once PageRanges attribute is removed, the From/To Page range is not used
> As seen from the code read from native, it checks if pageRange attribute is null or not and then read the range and since we are deleting it, the `pageRangesAttr ` will be null.
>
>
> protected final int getFromPageAttrib() {
> if (attributes != null) {
> PageRanges pageRangesAttr =
> (PageRanges)attributes.get(PageRanges.class);
> if (pageRangesAttr != null) {
> int[][] range = pageRangesAttr.getMembers();
> return range[0][0];
> }
> }
> return getMinPageAttrib();
> }
I added one more job to print page range 2-4
after 1st job of printing 2-3 and 2nd job of ALL pages which works so it seems just removing PageRanges attribute is enough and it will recreate PageRanges when range of pages is to be printed..
Let me know if you see any other problem..
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29312#discussion_r2719394012
More information about the client-libs-dev
mailing list