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

NullPointerException in RasterPrinterJob without PrinterResolution

XMLWordPrintable

    • 2d
    • b15
    • x86_64
    • windows_10

        ADDITIONAL SYSTEM INFORMATION :
        Windows 10, OpenJDK 64-Bit Server VM 11.0.2

        A DESCRIPTION OF THE PROBLEM :
        Printing to HP Deskjet 1510 printer fails with

        java.lang.NullPointerException
        at java.desktop/sun.print.RasterPrinterJob.setAttributes(RasterPrinterJob.java:1280)
        at java.desktop/sun.awt.windows.WPrinterJob.setAttributes(WPrinterJob.java:696)
        at java.desktop/sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1550)
        at java.desktop/sun.print.RasterPrinterJob.print(RasterPrinterJob.java:1483)

        This problem has been reported before as https://bugs.openjdk.java.net/browse/JDK-8186987 and has been and currently still is marked as fixed for Java 10. However, the error still occurs for Java 11! This is not much of a surprise, because the inital fix http://hg.openjdk.java.net/jdk10/client/jdk/file/dbb5b171a16b/src/java.desktop/windows/classes/sun/print/Win32PrintService.java#l1189 has been stripped from the corresponding repository! I think you should at least re-open issues if you strip away the corresponding fixes.

        Finally, a very simple fix for this issue would be:
        src/java.desktop/share/classes/sun/print/RasterPrinterJob.java
        1279,1282c1279,1284
        < double xr =
        < printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI);
        < double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI);
        < setXYRes(xr, yr);
        ---
        > if (isSupportedValue(printerResAttr, attributes)) {
        > double xr =
        > printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI);
        > double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI);
        > setXYRes(xr, yr);
        > }

        REGRESSION : Last worked in version 8u201

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        see https://bugs.openjdk.java.net/browse/JDK-8186987

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        see https://bugs.openjdk.java.net/browse/JDK-8186987
        ACTUAL -
        see https://bugs.openjdk.java.net/browse/JDK-8186987

        ---------- BEGIN SOURCE ----------
        see https://bugs.openjdk.java.net/browse/JDK-8186987
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        see https://bugs.openjdk.java.net/browse/JDK-8186987

        FREQUENCY : always


              psadhukhan Prasanta Sadhukhan
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated:
                Resolved: