--- old/src/java.base/share/native/libjava/System.c 2018-11-15 13:31:32.402887347 -0800 +++ new/src/java.base/share/native/libjava/System.c 2018-11-15 13:31:32.134887339 -0800 @@ -305,19 +305,6 @@ */ InitializeEncoding(env, sprops->sun_jnu_encoding); - /* Printing properties */ - /* Note: java.awt.printerjob is an implementation private property which - * just happens to have a java.* name because it is referenced in - * a java.awt class. It is the mechanism by which the implementation - * finds the appropriate class in the JRE for the platform. - * It is explicitly not designed to be overridden by clients as - * a way of replacing the implementation class, and in any case - * the mechanism by which the class is loaded is constrained to only - * find and load classes that are part of the JRE. - * This property may be removed if that mechanism is redesigned - */ - PUTPROP(props, "java.awt.printerjob", sprops->printerJob); - /* data model */ if (sizeof(sprops) == 4) { sprops->data_model = "32"; --- old/src/java.base/share/native/libjava/java_props.h 2018-11-15 13:31:32.890887360 -0800 +++ new/src/java.base/share/native/libjava/java_props.h 2018-11-15 13:31:32.626887353 -0800 @@ -74,7 +74,6 @@ char *sun_stderr_encoding; char *timezone; - char *printerJob; char *graphics_env; char *awt_toolkit; --- old/src/java.base/unix/native/libjava/java_props_md.c 2018-11-15 13:31:33.386887374 -0800 +++ new/src/java.base/unix/native/libjava/java_props_md.c 2018-11-15 13:31:33.122887367 -0800 @@ -391,13 +391,6 @@ } #endif /* MACOSX */ - /* Printing properties */ -#ifdef MACOSX - sprops.printerJob = "sun.lwawt.macosx.CPrinterJob"; -#else - sprops.printerJob = "sun.print.PSPrinterJob"; -#endif - /* patches/service packs installed */ sprops.patch_level = "unknown"; --- old/src/java.base/windows/native/libjava/java_props_md.c 2018-11-15 13:31:33.906887389 -0800 +++ new/src/java.base/windows/native/libjava/java_props_md.c 2018-11-15 13:31:33.642887382 -0800 @@ -375,9 +375,6 @@ sprops.tmp_dir = _wcsdup(tmpdir); } - /* Printing properties */ - sprops.printerJob = "sun.awt.windows.WPrinterJob"; - /* Java2D properties */ sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment"; --- old/src/java.desktop/share/classes/java/awt/print/PrinterJob.java 2018-11-15 13:31:34.426887404 -0800 +++ new/src/java.desktop/share/classes/java/awt/print/PrinterJob.java 2018-11-15 13:31:34.146887396 -0800 @@ -72,20 +72,7 @@ if (security != null) { security.checkPrintJobAccess(); } - return java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public PrinterJob run() { - String nm = System.getProperty("java.awt.printerjob", null); - try { - return (PrinterJob)Class.forName(nm). - getConstructor().newInstance(); - } catch (ClassNotFoundException e) { - throw new AWTError("PrinterJob not found: " + nm); - } catch (ReflectiveOperationException e) { - throw new AWTError("Could not instantiate PrinterJob: " + nm); - } - } - }); + return sun.print.PlatformPrinterJobProxy.getPrinterJob(); } /** --- /dev/null 2018-11-07 11:33:20.971245453 -0800 +++ new/src/java.desktop/macosx/classes/sun/print/PlatformPrinterJobProxy.java 2018-11-15 13:31:34.658887410 -0800 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.print; + +import java.awt.print.PrinterJob; + +public class PlatformPrinterJobProxy { + + public static PrinterJob getPrinterJob() { + return new sun.lwawt.macosx.CPrinterJob(); + } +} + + --- /dev/null 2018-11-07 11:33:20.971245453 -0800 +++ new/src/java.desktop/share/classes/sun/print/PlatformPrinterJobProxy.java 2018-11-15 13:31:35.210887426 -0800 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.print; + +import java.awt.print.PrinterJob; + +public class PlatformPrinterJobProxy { + + public static PrinterJob getPrinterJob() { + return new sun.print.PSPrinterJob(); + } +} + + --- /dev/null 2018-11-07 11:33:20.971245453 -0800 +++ new/src/java.desktop/windows/classes/sun/print/PlatformPrinterJobProxy.java 2018-11-15 13:31:35.754887441 -0800 @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.print; + +import java.awt.print.PrinterJob; + +public class PlatformPrinterJobProxy { + + public static PrinterJob getPrinterJob() { + return new sun.awt.windows.WPrinterJob(); + } +} + + --- /dev/null 2018-11-07 11:33:20.971245453 -0800 +++ new/test/jdk/java/awt/print/PrinterJob/CheckPrinterJobSystemProperty.java 2018-11-15 13:31:36.242887455 -0800 @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @run CheckPrinterJobSystemProperty + * @bug 8130264 + * @summary verify the PrinterJob implementation class name is not + * polluting system properties + */ + +public class CheckPrinterJobSystemProperty { + + public static void main(String[] args) { + String pjProp = System.getProperty("java.awt.printerjob"); + if (pjProp != null) { + throw new RuntimeException("pjProp = " + pjProp); + } + } +}