mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-15 08:34:30 +02:00
8130264: change the mechanism by which JDK loads the platform-specific PrinterJob implementation
Reviewed-by: serb, rriggs
This commit is contained in:
parent
e4a3d4e455
commit
7fe615f9a7
9 changed files with 152 additions and 38 deletions
|
@ -206,19 +206,6 @@ Java_jdk_internal_util_SystemProps_00024Raw_platformProperties(JNIEnv *env, jcla
|
|||
/* patch level */
|
||||
PUTPROP(propArray, _sun_os_patch_level_NDX, sprops->patch_level);
|
||||
|
||||
/* 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(propArray, _java_awt_printerjob_NDX, sprops->printerJob);
|
||||
|
||||
PUTPROP(propArray, _awt_toolkit_NDX, sprops->awt_toolkit);
|
||||
|
||||
/* Java2D properties */
|
||||
|
|
|
@ -69,7 +69,6 @@ typedef struct {
|
|||
char *sun_stdout_encoding;
|
||||
char *sun_stderr_encoding;
|
||||
|
||||
char *printerJob;
|
||||
char *graphics_env;
|
||||
char *awt_toolkit;
|
||||
|
||||
|
|
|
@ -391,13 +391,6 @@ GetJavaProperties(JNIEnv *env)
|
|||
}
|
||||
#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 = NULL; // leave it undefined
|
||||
|
||||
|
|
|
@ -376,9 +376,6 @@ GetJavaProperties(JNIEnv* env)
|
|||
sprops.tmp_dir = _wcsdup(tmpdir);
|
||||
}
|
||||
|
||||
/* Printing properties */
|
||||
sprops.printerJob = "sun.awt.windows.WPrinterJob";
|
||||
|
||||
/* Java2D properties */
|
||||
sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment";
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -72,20 +72,7 @@ public abstract class PrinterJob {
|
|||
if (security != null) {
|
||||
security.checkPrintJobAccess();
|
||||
}
|
||||
return java.security.AccessController.doPrivileged(
|
||||
new java.security.PrivilegedAction<PrinterJob>() {
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue