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

Getting NullPointerException while accessing the Print method of RasterPrinterJo

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10 , Java 12-ea19

      A DESCRIPTION OF THE PROBLEM :
      This is a similar issue as JDK-8193355 : Getting NullPointerException in RasterPrinterJob class while accessing the print () of Printable interface

      The exception occurs now on line 1280
      Caused by: java.lang.NullPointerException: null
              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)




      REGRESSION : Last worked in version 12

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      public void actionPerformed(ActionEvent e) {
               PrinterJob job = PrinterJob.getPrinterJob();
               job.setPrintable(this);
               boolean ok = job.printDialog();
               if (ok) {
                   try {
                        job.print();
                   } catch (PrinterException ex) {
                    /* The job did not successfully complete */
                   }
               }
          }

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The page should print correctly
      ACTUAL -
      A nullpointer exception is thrown

      ---------- BEGIN SOURCE ----------
      public void actionPerformed(ActionEvent e) {
               PrinterJob job = PrinterJob.getPrinterJob();
               job.setPrintable(this);
               boolean ok = job.printDialog();
               if (ok) {
                   try {
                        job.print();
                   } catch (PrinterException ex) {
                    /* The job did not successfully complete */
                   }
               }
          }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              pardesha Pardeep Sharma
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: