JDK-2121720 : UnixPrintServiceLookup should not require file permission
  • Type: Backport
  • Backport of: JDK-4930594
  • Component: client-libs
  • Sub-Component: 2d
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2004-12-03
  • Updated: 2008-02-06
  • Resolved: 2004-12-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.2_08 b01Fixed
Description
From an Applet, trying to do a print using PrintJob.getGraphics() returns 'null'. This happens in Solaris and not in Windows. The same code works fine when running as Application on Solaris.

Code snippet:
  //Inside an action handler of a Frame created from Applet
  PrintJob pj = getToolkit().getPrintJob(this, "Test Print", null);
  if(pj == null) return;
  Graphics g = pj.getGraphics();  // <== NULL 

Testcase is in the attachment of this bug. Open the demoDefault.html in Netscape browser on Solaris. Click on the Print button from the Frame, which brings up 'Confirmation Needed - Print' dialog (for the 1st time). Click the Yes button to continue, which brings up the 'Print' dialog. Click the OK button to print. Open the Java Console and see java.lang.NullPointerException being thrown.


###@###.### 2004-12-03 08:07:57 GMT

Comments
SUGGESTED FIX Back port the fix from tiger fix for 4930594. Webrev: http://javaweb.sfbay.sun.com/jcg/1.5.0-tiger/2D/4930594/ ###@###.### 2004-12-03 08:07:57 GMT
03-12-2004

EVALUATION On unix platform, calling sun.awt.motif.MToolkit.getPrintJob() would show the printDilaog and internally UnixPrintServiceLookup tries to create a temp file to get all the available printer names. When running as application it works fine but as an applet the code throws java.lang.SecurityException, which is caught internally and returned as 'null'. ###@###.### 2004-12-03 08:07:57 GMT
03-12-2004