On Thu, 5 Mar 2026 12:29:18 GMT, Prasanta Sadhukhan <[email protected]> 
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.
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Test update

Marked as reviewed by aivanov (Reviewer).

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

> 35:  */
> 36: 
> 37: public class TestPrintNoException {

Woud `TestPrintAllPagesNoException` be more descriptive of the purpose?

test/jdk/java/awt/PrintJob/TestPrintNoException.java line 47:

> 45: 
> 46:                 The test will fail automatically if the bug exists.
> 47:                 Note: There's no need to verify the actual print 
> output.""";

This test doesn't even print anything, you could state it clearer.

test/jdk/java/awt/PrintJob/TestPrintNoException.java line 62:

> 60:         Button b = new Button("Print");
> 61:         b.addActionListener((e) -> {
> 62:             PrintJob pj = frame.getToolkit().getPrintJob(frame, 
> "ResolutionTest", null);

Perhaps, the title of the frame could be more descriptive… although the frame 
width is likely so small that title isn't visible.

The title of the print job could also correspond to the name of the test. (I 
got that you copied the test from 
`java/awt/PrintJob/ScaledImagePrintingTest.java`.)

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

PR Review: https://git.openjdk.org/jdk/pull/29874#pullrequestreview-3896507086
PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2890018828
PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2890022768
PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2890042958

Reply via email to