RFR: 8378417: Printing All pages results in NPE for 1.1 PrintJob

Phil Race prr at openjdk.org
Mon Feb 23 21:33:24 UTC 2026


On Mon, 23 Feb 2026 02:23:41 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> After [JDK-8373239](https://bugs.openjdk.org/browse/JDK-8373239):, Printing ALL pages results in NPE for 1.1 PrintJob because of lack of set pageranges citing
> 
> Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException: Cannot invoke "javax.print.attribute.standard.PageRanges.getMembers()" because "range" is null
>         at java.desktop/sun.print.PrintJobDelegate.updateAttributes(PrintJobDelegate.java:529)
>         at java.desktop/sun.print.PrintJobDelegate.printDialog(PrintJobDelegate.java:424)
>         at java.desktop/sun.print.PrintJob2D.printDialog(PrintJob2D.java:65)
>         at java.desktop/sun.awt.windows.WToolkit.getPrintJob(WToolkit.java:644)
>         at java.desktop/sun.awt.windows.WToolkit.getPrintJob(WToolkit.java:629) 
> 
> A null check is now added as we are now removing PageRange attribute if not set..It works fine for PrinterJob but fails for 1.1 PrintJob as PrintJobDelegate.updateAttributes called in 1.1 PrintJob use pageRange variable without checking if it exists.

src/java.desktop/share/classes/sun/print/PrintJobDelegate.java line 529:

> 527: 
> 528:         PageRanges range = (PageRanges)attributes.get(PageRanges.class);
> 529:         if (range != null) {

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.

test/jdk/java/awt/PrintJob/ScaledImagePrintingTest.java line 37:

> 35: /*
> 36:  * @test
> 37:  * @bug 4257962 8378417

What does this test have to do with PageRanges ?

How do I use this to see the problem ?

 I think we need a more appropriate test.

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

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


More information about the client-libs-dev mailing list