[OpenJDK 2D-Dev] NPE in Java Print

Sergey Bylokhov Sergey.Bylokhov at oracle.com
Thu May 9 20:04:42 UTC 2019

Hi, Mark.

Thank you for the report, it looks like it is duplicate of the same bug:

The fix was pushed to JDK 13 and JDK 11.0.5.

On 09/05/2019 12:52, Mark A. Claassen wrote:
> In trying to be helpful to the OpenJDK community, I wanted to report a bug.  Not sure what the best way is to do this right now, so I reported it to Oracle, and now on this list.  (The Oracle bug is still being reviewed (Internal review ID : 9060615).
> Anyway, I found the NPE and "fixed it" by guarding against the NULL value.  This change below works for me.
> We have 3 HP printers, two of them could not print until I implemented this work-around.  With this, everything seems to work fine.
> (I told Oracle that I thought the two failing printers were color, but I apparently only one of those was color.  Sorry.)
> I am not sure if this is a valid bug fix, or the real error is in the object creating the attributes; it doesn't look like the other attributes can be NULL.
> "printerResAttr" is "protected", but I could find no other reference to it in the Java source code.
> Anyway, for us, these two printers cannot print with any released version of Java 11 or Java 12.  I submitted a test program with the Oracle bug report, but can also supply them here if that would help.
> Thanks for your time,
> Mark
> -----------------------
> Changed Lines 1273-1285 in sun.print.RasterPrinterJob
>          printerResAttr = (PrinterResolution)attributes.get(PrinterResolution.class);
>          if (service.isAttributeCategorySupported(PrinterResolution.class)) {
>              if (!isSupportedValue(printerResAttr,  attributes)) {
>                 printerResAttr = (PrinterResolution)
>                     service.getDefaultAttributeValue(PrinterResolution.class);
>              }
>              if (printerResAttr != null) { //LINE ADDED
>                  double xr =
>                     printerResAttr.getCrossFeedResolution(ResolutionSyntax.DPI);
>                  double yr = printerResAttr.getFeedResolution(ResolutionSyntax.DPI);
>                  setXYRes(xr, yr);
>              } //LINE ADDED
>          }
> Mark Claassen
> Senior Software Engineer
> Donnell Systems, Inc.
> 130 South Main Street
> Leighton Plaza Suite 375
> South Bend, IN  46601
> E-mail: mailto:mclaassen at ocie.net
> Voice: (574)232-3784
> Fax: (574)232-4014
> -------------------------------------------
> Confidentiality Notice: OCIESERVICE
> -------------------------------------------
> The contents of this e-mail message and any attachments are intended solely for the addressee(s) named in this message. This communication is intended to be and to remain confidential. If you are not the intended recipient of this message, or if this message has been addressed to you in error, please immediately alert the sender by reply e-mail and then delete this message and its attachments. Do not deliver, distribute, copy, disclose the contents or take any action in reliance upon the information contained in the communication or any attachments.

Best regards, Sergey.

More information about the 2d-dev mailing list