-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 17, 18, 21
-
b27
On at least JDK18+
java/awt/print/PrinterJob/PrinterDevice.java fails on macOS
====
% java PrinterDevice.java
Exception in thread "main" java.awt.print.PrinterException
at java.desktop/sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:394)
at PrinterDevice.main(PrinterDevice.java:56)
Caused by: java.lang.NullPointerException: Cannot read field "m00" because "Tx" is null
at java.desktop/java.awt.geom.AffineTransform.<init>(AffineTransform.java:490)
at java.desktop/sun.print.PrinterGraphicsConfig.getDefaultTransform(PrinterGraphicsConfig.java:105)
at PrinterDevice.print(PrinterDevice.java:68)
at java.desktop/sun.lwawt.macosx.CPrinterJob$6.run(CPrinterJob.java:826)
at java.desktop/sun.lwawt.macosx.CPrinterJob.printAndGetPageFormatArea(CPrinterJob.java:845)
at java.desktop/sun.lwawt.macosx.CPrinterJob.printLoop(Native Method)
at java.desktop/sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:368)
at PrinterDevice.main(PrinterDevice.java:56)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:484)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:208)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:135)
===
However I believe it has failed for much longer than that (!)
JDK 18 has a fix
https://bugs.openjdk.org/browse/JDK-8262731:
[macOS] Exception from "Printable.print" is swallowed during "PrinterJob.print"
I just confirmed this - it reproduces all the way back to JDK 8 (at least!)
In other words, before JDK 18 we were incorrectly hiding the problem.
java/awt/print/PrinterJob/PrinterDevice.java fails on macOS
====
% java PrinterDevice.java
Exception in thread "main" java.awt.print.PrinterException
at java.desktop/sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:394)
at PrinterDevice.main(PrinterDevice.java:56)
Caused by: java.lang.NullPointerException: Cannot read field "m00" because "Tx" is null
at java.desktop/java.awt.geom.AffineTransform.<init>(AffineTransform.java:490)
at java.desktop/sun.print.PrinterGraphicsConfig.getDefaultTransform(PrinterGraphicsConfig.java:105)
at PrinterDevice.print(PrinterDevice.java:68)
at java.desktop/sun.lwawt.macosx.CPrinterJob$6.run(CPrinterJob.java:826)
at java.desktop/sun.lwawt.macosx.CPrinterJob.printAndGetPageFormatArea(CPrinterJob.java:845)
at java.desktop/sun.lwawt.macosx.CPrinterJob.printLoop(Native Method)
at java.desktop/sun.lwawt.macosx.CPrinterJob.print(CPrinterJob.java:368)
at PrinterDevice.main(PrinterDevice.java:56)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at jdk.compiler/com.sun.tools.javac.launcher.Main.execute(Main.java:484)
at jdk.compiler/com.sun.tools.javac.launcher.Main.run(Main.java:208)
at jdk.compiler/com.sun.tools.javac.launcher.Main.main(Main.java:135)
===
However I believe it has failed for much longer than that (!)
JDK 18 has a fix
https://bugs.openjdk.org/browse/JDK-8262731:
[macOS] Exception from "Printable.print" is swallowed during "PrinterJob.print"
I just confirmed this - it reproduces all the way back to JDK 8 (at least!)
In other words, before JDK 18 we were incorrectly hiding the problem.