Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions java/awt/print/PrinterJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import gnu.java.awt.print.JavaPrinterJob;

import java.awt.HeadlessException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.DocFlavor;
Expand All @@ -64,6 +66,36 @@ public abstract class PrinterJob
*/
public static PrinterJob getPrinterJob()
{
// As in the JDK, the system property java.awt.printerjob can name
// the class. Load it as Toolkit loads awt.toolkit, so that a class
// on the class path also works.
String name = gnu.classpath.SystemProperties.getProperty("java.awt.printerjob");
if (name != null)
{
Throwable error;
try
{
ClassLoader cl = (ClassLoader) AccessController.doPrivileged
(new PrivilegedAction()
{
public Object run()
{
return ClassLoader.getSystemClassLoader();
}
});
return (PrinterJob) Class.forName(name, true, cl).newInstance();
}
catch (Exception e)
{
error = e;
}
catch (LinkageError e)
{
error = e;
}
System.err.println("PrinterJob: cannot use java.awt.printerjob="
+ name + " (" + error + "), using the default");
}
return new JavaPrinterJob();
}

Expand Down
Loading