Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8320443

[macos] Test java/awt/print/PrinterJob/PrinterDevice.java fails on macOS

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 22
    • 8, 11, 17, 18, 21
    • client-libs
    • 2d
    • 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.

            prr Philip Race
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: