On Thu, 5 Mar 2026 17:10:05 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: > > AUtomate test test/jdk/java/awt/PrintJob/TestPrintNoException.java line 50: > 48: }); > 49: Toolkit tk = Toolkit.getDefaultToolkit(); > 50: PrintJob pj = null; `pj` can be declared where it's used. You may still call `pj.end()` to indicate the test doesn't print anything. test/jdk/java/awt/PrintJob/TestPrintNoException.java line 62: > 60: Frame testFrame = new Frame("print"); > 61: try { > 62: if (tk != null) { `tk` can never be `null`. test/jdk/java/awt/PrintJob/TestPrintNoException.java line 64: > 62: if (tk != null) { > 63: t.start(); > 64: pj = tk.getPrintJob(testFrame, null, ja, null); The original test used Toolkit.getPrintJob with three parameters. Why does automated test need explicit attributes? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2891338455 PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2891334698 PR Review Comment: https://git.openjdk.org/jdk/pull/29874#discussion_r2891332225
