changeset 52994:c57f1850d44f

8212703: Remove sun.java2d.fontpath property from java launcher code Reviewed-by: alanb, rriggs
author prr
date Mon, 10 Dec 2018 12:33:23 -0800
parents c00ce2c36143
children 8e26761a2c2e
files src/java.base/share/classes/jdk/internal/util/SystemProps.java src/java.base/share/native/libjava/System.c src/java.base/share/native/libjava/java_props.h src/java.base/unix/native/libjava/java_props_md.c src/java.base/windows/native/libjava/java_props_md.c test/jdk/java/awt/font/FontPathEnvTest/FontPathEnvTest.java
diffstat 6 files changed, 92 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/jdk/internal/util/SystemProps.java	Fri Dec 07 09:38:07 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/util/SystemProps.java	Mon Dec 10 12:33:23 2018 -0800
@@ -92,7 +92,6 @@
         putIfAbsent(props, "java.awt.headless", raw.propDefault(Raw._java_awt_headless_NDX));
         putIfAbsent(props, "java.awt.graphicsenv", raw.propDefault(Raw._java_awt_graphicsenv_NDX));
         putIfAbsent(props, "sun.desktop", raw.propDefault(Raw._sun_desktop_NDX));
-        putIfAbsent(props, "sun.java2d.fontpath", raw.propDefault(Raw._sun_java2d_fontpath_NDX));
         putIfAbsent(props, "sun.arch.abi", raw.propDefault(Raw._sun_arch_abi_NDX));
         putIfAbsent(props, "sun.arch.data.model", raw.propDefault(Raw._sun_arch_data_model_NDX));
         putIfAbsent(props, "sun.os.patch.level", raw.propDefault(Raw._sun_os_patch_level_NDX));
@@ -219,8 +218,7 @@
         @Native private static final int _sun_cpu_isalist_NDX = 1 + _sun_cpu_endian_NDX;
         @Native private static final int _sun_desktop_NDX = 1 + _sun_cpu_isalist_NDX;
         @Native private static final int _sun_io_unicode_encoding_NDX = 1 + _sun_desktop_NDX;
-        @Native private static final int _sun_java2d_fontpath_NDX = 1 + _sun_io_unicode_encoding_NDX;
-        @Native private static final int _sun_jnu_encoding_NDX = 1 + _sun_java2d_fontpath_NDX;
+        @Native private static final int _sun_jnu_encoding_NDX = 1 + _sun_io_unicode_encoding_NDX;
         @Native private static final int _sun_os_patch_level_NDX = 1 + _sun_jnu_encoding_NDX;
         @Native private static final int _sun_stderr_encoding_NDX = 1 + _sun_os_patch_level_NDX;
         @Native private static final int _sun_stdout_encoding_NDX = 1 + _sun_stderr_encoding_NDX;
--- a/src/java.base/share/native/libjava/System.c	Fri Dec 07 09:38:07 2018 +0530
+++ b/src/java.base/share/native/libjava/System.c	Mon Dec 10 12:33:23 2018 -0800
@@ -220,7 +220,6 @@
      * This property may be removed if that mechanism is redesigned
      */
     PUTPROP(propArray, _java_awt_graphicsenv_NDX, sprops->graphics_env);
-    PUTPROP_PlatformString(propArray, _sun_java2d_fontpath_NDX, sprops->font_dir);
 
     /*
      * The sun.desktop property is currently only set for Gnome and Windows desktops.
--- a/src/java.base/share/native/libjava/java_props.h	Fri Dec 07 09:38:07 2018 +0530
+++ b/src/java.base/share/native/libjava/java_props.h	Mon Dec 10 12:33:23 2018 -0800
@@ -46,7 +46,6 @@
 #endif
 
     nchar *tmp_dir;
-    nchar *font_dir;
     nchar *user_dir;
 
     char *file_separator;
--- a/src/java.base/unix/native/libjava/java_props_md.c	Fri Dec 07 09:38:07 2018 +0530
+++ b/src/java.base/unix/native/libjava/java_props_md.c	Mon Dec 10 12:33:23 2018 -0800
@@ -407,10 +407,6 @@
     sprops.awt_toolkit = "sun.awt.X11.XToolkit";
 #endif
 
-    /* This is used only for debugging of font problems. */
-    v = getenv("JAVA2D_FONTPATH");
-    sprops.font_dir = v ? v : NULL;
-
 #ifdef SI_ISALIST
     /* supported instruction sets */
     {
--- a/src/java.base/windows/native/libjava/java_props_md.c	Fri Dec 07 09:38:07 2018 +0530
+++ b/src/java.base/windows/native/libjava/java_props_md.c	Mon Dec 10 12:33:23 2018 -0800
@@ -379,11 +379,6 @@
     /* Java2D properties */
     sprops.graphics_env = "sun.awt.Win32GraphicsEnvironment";
 
-    {    /* This is used only for debugging of font problems. */
-        WCHAR *path = _wgetenv(L"JAVA2D_FONTPATH");
-        sprops.font_dir = (path != NULL) ? _wcsdup(path) : NULL;
-    }
-
     /* OS properties */
     {
         char buf[100];
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/awt/font/FontPathEnvTest/FontPathEnvTest.java	Mon Dec 10 12:33:23 2018 -0800
@@ -0,0 +1,91 @@
+/*
+ * 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
+ * @bug      8212703
+ * @summary  Test JAVA2D_FONTPATH env. var does not set a system property
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class FontPathEnvTest {
+
+    public static void main(String args[]) {
+        String env = System.getenv("JAVA2D_FONTPATH");
+        if (env == null) {
+           createChild();
+        } else {
+            String prop = System.getProperty("sun.java2d.fontpath");
+            if (prop != null && env.equals(prop)) {
+                throw new RuntimeException("sun.java2d.fontpath property set");
+            }
+        }
+    }
+
+    static void createChild() {
+        String cpDir = System.getProperty("java.class.path");
+        Map<String, String> env = new HashMap<String, String>();
+        env.put("JAVA2D_FONTPATH", "anyValue");
+        String jHome = System.getProperty("java.home");
+        String jCmd = jHome + File.separator + "bin" + File.separator + "java";
+        int exitValue = doExec(env, jCmd, "-cp", cpDir, "FontPathEnvTest");
+        if (exitValue != 0) {
+            throw new RuntimeException("Test Failed");
+        }
+    }
+
+    static int doExec(Map<String, String> envToSet, String... cmds) {
+        Process p = null;
+        ProcessBuilder pb = new ProcessBuilder(cmds);
+        Map<String, String> env = pb.environment();
+        for (String cmd : cmds) {
+            System.out.print(cmd + " ");
+        }
+        System.out.println();
+        if (envToSet != null) {
+            env.putAll(envToSet);
+        }
+        BufferedReader rdr = null;
+        try {
+            pb.redirectErrorStream(true);
+            p = pb.start();
+            rdr = new BufferedReader(new InputStreamReader(p.getInputStream()));
+            String in = rdr.readLine();
+            while (in != null) {
+                in = rdr.readLine();
+                System.out.println(in);
+            }
+            p.waitFor();
+            p.destroy();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return p.exitValue();
+    }
+}