/* * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved. * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ package com.sun.javafx.runtime; import java.io.InputStream; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Hashtable; public class SystemProperties { /** * JavaFX System Properties table. * First column represents javafx property name with "javafx" prefix stripped off. * Second column represents underlying runtime platform equivalent. * "jfx_specific" value in the runtime platform equivalent field indicates the property is JavaFX specific. * Empty string in the runtime platform equivalent field indicates thete is no equivalent property for given platform. */ private static final String[] sysprop_table = { /*"javafx.*/"application.codebase", "jfx_specific", /*"javafx.*/"debug", "javafx.debug" }; /** * JavaFX Specific System Properties table. * First column represents javafx environment specific property name with "javafx" prefix stripped off. * Second column represents value of the property */ private static final String[] jfxprop_table = { /*"javafx.*/"application.codebase", "", }; private static final Hashtable sysprop_list = new Hashtable(); private static final Hashtable jfxprop_list = new Hashtable(); private static final String versionResourceName = "/com/sun/javafx/runtime/resources/version.properties"; private static boolean isDebug; static { AccessController.doPrivileged((PrivilegedAction) () -> { addProperties (sysprop_table, false); addProperties (jfxprop_table, true); setVersions(); isDebug = "true".equalsIgnoreCase(getProperty("javafx.debug")); return null; }); } /* * Populate our well known version strings */ private static void setVersions() { int size; InputStream is = SystemProperties.class.getResourceAsStream(versionResourceName); try { size = is.available(); byte[] b = new byte[size]; int n = is.read(b); String inStr = new String(b, "utf-8"); SystemProperties.setFXProperty("javafx.version", getValue(inStr, "release=")); SystemProperties.setFXProperty("javafx.runtime.version", getValue(inStr, "full=")); } catch (Exception ignore) { } } /* * Returns a value given a name */ private static String getValue(String toSearch, String name) { String s = toSearch; int index; while ((index = s.indexOf(name)) != -1) { s = s.substring(index); if ((index = s.indexOf(0x0A))!= -1) { return (s.substring(name.length(), index)).trim(); } return (s.substring(name.length(), s.length())).trim(); } return "unknown"; } /** * Registers a statically allocated System Properties table * Once registered properties listed in the table are availabe for inquiry through FX.getProperty(). * Table is defined as a String array with JavaFX property name followed by property value or property mapping identifier * depending on whether the table contains JavaFX specific properties or not. * Note that JavaFX property names have "javafx" stripped out to optimize table lookup. * The following identifiers are available: *
* 1. Underlying runtime platform property name. When listed, FX.getProperty() will invoke System.getProperty() * method to retrieve property value. * example: * {"version", "java.version"} * * 2. "javafx_specific". When listed indicates there is no association between the property and underlying runtime * platform. Rather the property is JavaFX specific. In that case another table needs to be provided with values * for all JavaFX specific properties. JavaFX specific properties table is a string array containing property name * and corresponding property value. * example: * {"hw.radio", "none"} * * 3. Empty string. When listed, the meaning there is no association between the property and underlying runtime * platform nor the property is JavaFX specific. FX.getProperty() invoked on that property returns null. * example: * {"supports.mixing", "none"} * @param table System Properties table * @param jfx_specific Indicates the table contains JavaFX specific properties */ public static void addProperties (String[] table, boolean jfx_specific) { if (table == null) return; Hashtable props; if (jfx_specific) { props = jfxprop_list; } else { props = sysprop_list; } for (int i=0; i