Java Code Examples for sun.security.action.GetPropertyAction

The following examples show how to use sun.security.action.GetPropertyAction. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk8u-jdk   Source File: Debug.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Return the value of the boolean System property propName.
 *
 * Note use of doPrivileged(). Do make accessible to applications.
 */
static boolean getBooleanProperty(String propName, boolean defaultValue) {
    // if set, require value of either true or false
    String b = AccessController.doPrivileged(
            new GetPropertyAction(propName));
    if (b == null) {
        return defaultValue;
    } else if (b.equalsIgnoreCase("false")) {
        return false;
    } else if (b.equalsIgnoreCase("true")) {
        return true;
    } else {
        throw new RuntimeException("Value of " + propName
            + " must either be 'true' or 'false'");
    }
}
 
Example 2
Source Project: openjdk-jdk9   Source File: Locale.java    License: GNU General Public License v2.0 6 votes vote down vote up
private static Locale initDefault() {
    String language, region, script, country, variant;
    Properties props = GetPropertyAction.privilegedGetProperties();
    language = props.getProperty("user.language", "en");
    // for compatibility, check for old user.region property
    region = props.getProperty("user.region");
    if (region != null) {
        // region can be of form country, country_variant, or _variant
        int i = region.indexOf('_');
        if (i >= 0) {
            country = region.substring(0, i);
            variant = region.substring(i + 1);
        } else {
            country = region;
            variant = "";
        }
        script = "";
    } else {
        script = props.getProperty("user.script", "");
        country = props.getProperty("user.country", "");
        variant = props.getProperty("user.variant", "");
    }

    return getInstance(language, script, country, variant, null);
}
 
Example 3
Source Project: hottub   Source File: WindowsFileSystem.java    License: GNU General Public License v2.0 6 votes vote down vote up
WindowsFileSystem(WindowsFileSystemProvider provider,
                  String dir)
{
    this.provider = provider;

    // parse default directory and check it is absolute
    WindowsPathParser.Result result = WindowsPathParser.parse(dir);

    if ((result.type() != WindowsPathType.ABSOLUTE) &&
        (result.type() != WindowsPathType.UNC))
        throw new AssertionError("Default directory is not an absolute path");
    this.defaultDirectory = result.path();
    this.defaultRoot = result.root();

    PrivilegedAction<String> pa = new GetPropertyAction("os.version");
    String osversion = AccessController.doPrivileged(pa);
    String[] vers = Util.split(osversion, '.');
    int major = Integer.parseInt(vers[0]);
    int minor = Integer.parseInt(vers[1]);

    // symbolic links available on Vista and newer
    supportsLinks = (major >= 6);

    // enumeration of data streams available on Windows Server 2003 and newer
    supportsStreamEnumeration = (major >= 6) || (major == 5 && minor >= 2);
}
 
Example 4
Source Project: jdk8u-dev-jdk   Source File: JRSUIUtils.java    License: GNU General Public License v2.0 6 votes vote down vote up
static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
    // split the "10.x.y" version number
    String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
    String[] fragments = osVersion.split("\\.");

    // sanity check the "10." part of the version
    if (!fragments[0].equals("10")) return false;
    if (fragments.length < 2) return false;

    // check if os.version matches the given version using the given match method
    try {
        int minorVers = Integer.parseInt(fragments[1]);

        if (inclusive && minorVers == version) return true;
        if (matchBelow && minorVers < version) return true;
        if (matchAbove && minorVers > version) return true;

    } catch (NumberFormatException e) {
        // was not an integer
    }
    return false;
}
 
Example 5
Source Project: jdk8u-dev-jdk   Source File: Window.java    License: GNU General Public License v2.0 6 votes vote down vote up
private void setWarningString() {
    warningString = null;
    SecurityManager sm = System.getSecurityManager();
    if (sm != null) {
        try {
            sm.checkPermission(SecurityConstants.AWT.TOPLEVEL_WINDOW_PERMISSION);
        } catch (SecurityException se) {
            // make sure the privileged action is only
            // for getting the property! We don't want the
            // above checkPermission call to always succeed!
            warningString = AccessController.doPrivileged(
                  new GetPropertyAction("awt.appletWarning",
                                        "Java Applet Window"));
        }
    }
}
 
Example 6
Source Project: openjdk-jdk8u   Source File: JRSUIUtils.java    License: GNU General Public License v2.0 6 votes vote down vote up
static boolean currentMacOSXVersionMatchesGivenVersionRange(final int version, final boolean inclusive, final boolean matchBelow, final boolean matchAbove) {
    // split the "10.x.y" version number
    String osVersion = AccessController.doPrivileged(new GetPropertyAction("os.version"));
    String[] fragments = osVersion.split("\\.");

    // sanity check the "10." part of the version
    if (!fragments[0].equals("10")) return false;
    if (fragments.length < 2) return false;

    // check if os.version matches the given version using the given match method
    try {
        int minorVers = Integer.parseInt(fragments[1]);

        if (inclusive && minorVers == version) return true;
        if (matchBelow && minorVers < version) return true;
        if (matchAbove && minorVers > version) return true;

    } catch (NumberFormatException e) {
        // was not an integer
    }
    return false;
}
 
Example 7
Source Project: openjdk-8   Source File: GSSUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines if the application doesn't mind if the mechanism obtains
 * the required credentials from outside of the current Subject. Our
 * Kerberos v5 mechanism would do a JAAS login on behalf of the
 * application if this were the case.
 *
 * The application indicates this by explicitly setting the system
 * property javax.security.auth.useSubjectCredsOnly to false.
 */
public static boolean useSubjectCredsOnly(GSSCaller caller) {

    // HTTP/SPNEGO doesn't use the standard JAAS framework. Instead, it
    // uses the java.net.Authenticator style, therefore always return
    // false here.
    if (caller instanceof HttpCaller) {
        return false;
    }
    /*
     * Don't use GetBooleanAction because the default value in the JRE
     * (when this is unset) has to treated as true.
     */
    String propValue = AccessController.doPrivileged(
            new GetPropertyAction("javax.security.auth.useSubjectCredsOnly",
            "true"));
    /*
     * This property has to be explicitly set to "false". Invalid
     * values should be ignored and the default "true" assumed.
     */
    return (!propValue.equalsIgnoreCase("false"));
}
 
Example 8
Source Project: openjdk-jdk9   Source File: GSSUtil.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Determines if the application doesn't mind if the mechanism obtains
 * the required credentials from outside of the current Subject. Our
 * Kerberos v5 mechanism would do a JAAS login on behalf of the
 * application if this were the case.
 *
 * The application indicates this by explicitly setting the system
 * property javax.security.auth.useSubjectCredsOnly to false.
 */
public static boolean useSubjectCredsOnly(GSSCaller caller) {

    // HTTP/SPNEGO doesn't use the standard JAAS framework. Instead, it
    // uses the java.net.Authenticator style, therefore always return
    // false here.
    if (caller instanceof HttpCaller) {
        return false;
    }
    /*
     * Don't use GetBooleanAction because the default value in the JRE
     * (when this is unset) has to treated as true.
     */
    String propValue = AccessController.doPrivileged(
            new GetPropertyAction("javax.security.auth.useSubjectCredsOnly",
            "true"));
    /*
     * This property has to be explicitly set to "false". Invalid
     * values should be ignored and the default "true" assumed.
     */
    return (!propValue.equalsIgnoreCase("false"));
}
 
Example 9
Source Project: jdk8u60   Source File: Util.java    License: GNU General Public License v2.0 5 votes vote down vote up
static boolean atBugLevel(String bl) {              // package-private
    if (bugLevel == null) {
        if (!sun.misc.VM.isBooted())
            return false;
        String value = AccessController.doPrivileged(
            new GetPropertyAction("sun.nio.ch.bugLevel"));
        bugLevel = (value != null) ? value : "";
    }
    return bugLevel.equals(bl);
}
 
Example 10
Source Project: jdk1.8-source-analysis   Source File: Locale.java    License: Apache License 2.0 5 votes vote down vote up
private static Locale initDefault() {
    String language, region, script, country, variant;
    language = AccessController.doPrivileged(
        new GetPropertyAction("user.language", "en"));
    // for compatibility, check for old user.region property
    region = AccessController.doPrivileged(
        new GetPropertyAction("user.region"));
    if (region != null) {
        // region can be of form country, country_variant, or _variant
        int i = region.indexOf('_');
        if (i >= 0) {
            country = region.substring(0, i);
            variant = region.substring(i + 1);
        } else {
            country = region;
            variant = "";
        }
        script = "";
    } else {
        script = AccessController.doPrivileged(
            new GetPropertyAction("user.script", ""));
        country = AccessController.doPrivileged(
            new GetPropertyAction("user.country", ""));
        variant = AccessController.doPrivileged(
            new GetPropertyAction("user.variant", ""));
    }

    return getInstance(language, script, country, variant, null);
}
 
Example 11
Source Project: JDKSourceCode1.8   Source File: Charset.java    License: MIT License 5 votes vote down vote up
static boolean atBugLevel(String bl) {              // package-private
    String level = bugLevel;
    if (level == null) {
        if (!sun.misc.VM.isBooted())
            return false;
        bugLevel = level = AccessController.doPrivileged(
            new GetPropertyAction("sun.nio.cs.bugLevel", ""));
    }
    return level.equals(bl);
}
 
Example 12
Source Project: jdk8u_jdk   Source File: Locale.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static Locale initDefault(Locale.Category category) {
    return getInstance(
        AccessController.doPrivileged(
            new GetPropertyAction(category.languageKey, defaultLocale.getLanguage())),
        AccessController.doPrivileged(
            new GetPropertyAction(category.scriptKey, defaultLocale.getScript())),
        AccessController.doPrivileged(
            new GetPropertyAction(category.countryKey, defaultLocale.getCountry())),
        AccessController.doPrivileged(
            new GetPropertyAction(category.variantKey, defaultLocale.getVariant())),
        null);
}
 
Example 13
Source Project: jdk1.8-source-analysis   Source File: SwingUtilities.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns true if <code>setTransferHandler</code> should change the
 * <code>DropTarget</code>.
 */
private static boolean getSuppressDropTarget() {
    if (!checkedSuppressDropSupport) {
        suppressDropSupport = Boolean.valueOf(
            AccessController.doPrivileged(
                new GetPropertyAction("suppressSwingDropSupport")));
        checkedSuppressDropSupport = true;
    }
    return suppressDropSupport;
}
 
Example 14
Source Project: jdk1.8-source-analysis   Source File: UIManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the name of the <code>LookAndFeel</code> class that implements
 * the native system look and feel if there is one, otherwise
 * the name of the default cross platform <code>LookAndFeel</code>
 * class. This value can be overriden by setting the
 * <code>swing.systemlaf</code> system property.
 *
 * @return the <code>String</code> of the <code>LookAndFeel</code>
 *          class
 *
 * @see #setLookAndFeel
 * @see #getCrossPlatformLookAndFeelClassName
 */
public static String getSystemLookAndFeelClassName() {
    String systemLAF = AccessController.doPrivileged(
                         new GetPropertyAction("swing.systemlaf"));
    if (systemLAF != null) {
        return systemLAF;
    }
    OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
    if (osType == OSInfo.OSType.WINDOWS) {
        return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    } else {
        String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if ("gnome".equals(desktop) &&
                toolkit instanceof SunToolkit &&
                ((SunToolkit) toolkit).isNativeGTKAvailable()) {
            // May be set on Linux and Solaris boxs.
            return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        }
        if (osType == OSInfo.OSType.MACOSX) {
            if (toolkit.getClass() .getName()
                                   .equals("sun.lwawt.macosx.LWCToolkit")) {
                return "com.apple.laf.AquaLookAndFeel";
            }
        }
        if (osType == OSInfo.OSType.SOLARIS) {
            return "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        }
    }
    return getCrossPlatformLookAndFeelClassName();
}
 
Example 15
Source Project: TencentKona-8   Source File: SunToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static boolean useSystemAAFontSettings() {
    if (!checkedSystemAAFontSettings) {
        useSystemAAFontSettings = true; /* initially set this true */
        String systemAAFonts = null;
        Toolkit tk = Toolkit.getDefaultToolkit();
        if (tk instanceof SunToolkit) {
            systemAAFonts =
                AccessController.doPrivileged(
                     new GetPropertyAction("awt.useSystemAAFontSettings"));
        }
        if (systemAAFonts != null) {
            useSystemAAFontSettings =
                Boolean.valueOf(systemAAFonts).booleanValue();
            /* If it is anything other than "true", then it may be
             * a hint name , or it may be "off, "default", etc.
             */
            if (!useSystemAAFontSettings) {
                desktopFontHints = getDesktopAAHintsByName(systemAAFonts);
            }
        }
        /* If its still true, apply the extra condition */
        if (useSystemAAFontSettings) {
             useSystemAAFontSettings = lastExtraCondition;
        }
        checkedSystemAAFontSettings = true;
    }
    return useSystemAAFontSettings;
}
 
Example 16
Source Project: JDKSourceCode1.8   Source File: Locale.java    License: MIT License 5 votes vote down vote up
private static Locale initDefault() {
    String language, region, script, country, variant;
    language = AccessController.doPrivileged(
        new GetPropertyAction("user.language", "en"));
    // for compatibility, check for old user.region property
    region = AccessController.doPrivileged(
        new GetPropertyAction("user.region"));
    if (region != null) {
        // region can be of form country, country_variant, or _variant
        int i = region.indexOf('_');
        if (i >= 0) {
            country = region.substring(0, i);
            variant = region.substring(i + 1);
        } else {
            country = region;
            variant = "";
        }
        script = "";
    } else {
        script = AccessController.doPrivileged(
            new GetPropertyAction("user.script", ""));
        country = AccessController.doPrivileged(
            new GetPropertyAction("user.country", ""));
        variant = AccessController.doPrivileged(
            new GetPropertyAction("user.variant", ""));
    }

    return getInstance(language, script, country, variant, null);
}
 
Example 17
Source Project: jdk8u-jdk   Source File: Charset.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default charset of this Java virtual machine.
 *
 * <p> The default charset is determined during virtual-machine startup and
 * typically depends upon the locale and charset of the underlying
 * operating system.
 *
 * @return  A charset object for the default charset
 *
 * @since 1.5
 */
public static Charset defaultCharset() {
    if (defaultCharset == null) {
        synchronized (Charset.class) {
            String csn = AccessController.doPrivileged(
                new GetPropertyAction("file.encoding"));
            Charset cs = lookup(csn);
            if (cs != null)
                defaultCharset = cs;
            else
                defaultCharset = forName("UTF-8");
        }
    }
    return defaultCharset;
}
 
Example 18
Source Project: TencentKona-8   Source File: UnixFileSystem.java    License: GNU General Public License v2.0 5 votes vote down vote up
UnixFileSystem(UnixFileSystemProvider provider, String dir) {
    this.provider = provider;
    this.defaultDirectory = Util.toBytes(UnixPath.normalizeAndCheck(dir));
    if (this.defaultDirectory[0] != '/') {
        throw new RuntimeException("default directory must be absolute");
    }

    // if process-wide chdir is allowed or default directory is not the
    // process working directory then paths must be resolved against the
    // default directory.
    String propValue = AccessController.doPrivileged(
        new GetPropertyAction("sun.nio.fs.chdirAllowed", "false"));
    boolean chdirAllowed = (propValue.length() == 0) ?
        true : Boolean.valueOf(propValue);
    if (chdirAllowed) {
        this.needToResolveAgainstDefaultDirectory = true;
    } else {
        byte[] cwd = UnixNativeDispatcher.getcwd();
        boolean defaultIsCwd = (cwd.length == defaultDirectory.length);
        if (defaultIsCwd) {
            for (int i=0; i<cwd.length; i++) {
                if (cwd[i] != defaultDirectory[i]) {
                    defaultIsCwd = false;
                    break;
                }
            }
        }
        this.needToResolveAgainstDefaultDirectory = !defaultIsCwd;
    }

    // the root directory
    this.rootDirectory = new UnixPath(this, "/");
}
 
Example 19
Source Project: jdk8u-jdk   Source File: Charset.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the default charset of this Java virtual machine.
 *
 * <p> The default charset is determined during virtual-machine startup and
 * typically depends upon the locale and charset of the underlying
 * operating system.
 *
 * @return  A charset object for the default charset
 *
 * @since 1.5
 */
public static Charset defaultCharset() {
    if (defaultCharset == null) {
        synchronized (Charset.class) {
            String csn = AccessController.doPrivileged(
                new GetPropertyAction("file.encoding"));
            Charset cs = lookup(csn);
            if (cs != null)
                defaultCharset = cs;
            else
                defaultCharset = forName("UTF-8");
        }
    }
    return defaultCharset;
}
 
Example 20
@Override
FileTypeDetector getFileTypeDetector() {
    Path userMimeTypes = Paths.get(AccessController.doPrivileged(
        new GetPropertyAction("user.home")), ".mime.types");
    Path etcMimeTypes = Paths.get("/etc/mime.types");

    return chain(new GnomeFileTypeDetector(),
                 new MimeTypesFileTypeDetector(userMimeTypes),
                 new MimeTypesFileTypeDetector(etcMimeTypes));
}
 
Example 21
Source Project: TencentKona-8   Source File: JISAutoDetect.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returned EUC-JP Charset name is OS dependent
 */

private static String getEUCJPName() {
    String osName = AccessController.doPrivileged(
        new GetPropertyAction("os.name"));
    if (osName.equals("Solaris") || osName.equals("SunOS"))
        return("x-eucjp-open");
    else
        return("EUC_JP");
}
 
Example 22
Source Project: jdk8u_jdk   Source File: SunToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the locale in which the runtime was started.
 */
public static Locale getStartupLocale() {
    if (startupLocale == null) {
        String language, region, country, variant;
        language = AccessController.doPrivileged(
                        new GetPropertyAction("user.language", "en"));
        // for compatibility, check for old user.region property
        region = AccessController.doPrivileged(
                        new GetPropertyAction("user.region"));
        if (region != null) {
            // region can be of form country, country_variant, or _variant
            int i = region.indexOf('_');
            if (i >= 0) {
                country = region.substring(0, i);
                variant = region.substring(i + 1);
            } else {
                country = region;
                variant = "";
            }
        } else {
            country = AccessController.doPrivileged(
                            new GetPropertyAction("user.country", ""));
            variant = AccessController.doPrivileged(
                            new GetPropertyAction("user.variant", ""));
        }
        startupLocale = new Locale(language, country, variant);
    }
    return startupLocale;
}
 
Example 23
Source Project: openjdk-8   Source File: WindowsLookAndFeel.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void initialize() {
    super.initialize();

    // Set the flag which determines which version of Windows should
    // be rendered. This flag only need to be set once.
    // if version <= 4.0 then the classic LAF should be loaded.
    if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
        isClassicWindows = true;
    } else {
        isClassicWindows = false;
        XPStyle.invalidateStyle();
    }

    // Using the fonts set by the user can potentially cause
    // performance and compatibility issues, so allow this feature
    // to be switched off either at runtime or programmatically
    //
    String systemFonts = java.security.AccessController.doPrivileged(
           new GetPropertyAction("swing.useSystemFontSettings"));
    useSystemFontSettings = (systemFonts == null ||
                             Boolean.valueOf(systemFonts).booleanValue());

    if (useSystemFontSettings) {
        Object value = UIManager.get("Application.useSystemFontSettings");

        useSystemFontSettings = (value == null ||
                                 Boolean.TRUE.equals(value));
    }
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);

}
 
Example 24
Source Project: openjdk-8-source   Source File: UIManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the name of the <code>LookAndFeel</code> class that implements
 * the native system look and feel if there is one, otherwise
 * the name of the default cross platform <code>LookAndFeel</code>
 * class. This value can be overriden by setting the
 * <code>swing.systemlaf</code> system property.
 *
 * @return the <code>String</code> of the <code>LookAndFeel</code>
 *          class
 *
 * @see #setLookAndFeel
 * @see #getCrossPlatformLookAndFeelClassName
 */
public static String getSystemLookAndFeelClassName() {
    String systemLAF = AccessController.doPrivileged(
                         new GetPropertyAction("swing.systemlaf"));
    if (systemLAF != null) {
        return systemLAF;
    }
    OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
    if (osType == OSInfo.OSType.WINDOWS) {
        return "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
    } else {
        String desktop = AccessController.doPrivileged(new GetPropertyAction("sun.desktop"));
        Toolkit toolkit = Toolkit.getDefaultToolkit();
        if ("gnome".equals(desktop) &&
                toolkit instanceof SunToolkit &&
                ((SunToolkit) toolkit).isNativeGTKAvailable()) {
            // May be set on Linux and Solaris boxs.
            return "com.sun.java.swing.plaf.gtk.GTKLookAndFeel";
        }
        if (osType == OSInfo.OSType.MACOSX) {
            if (toolkit.getClass() .getName()
                                   .equals("sun.lwawt.macosx.LWCToolkit")) {
                return "com.apple.laf.AquaLookAndFeel";
            }
        }
        if (osType == OSInfo.OSType.SOLARIS) {
            return "com.sun.java.swing.plaf.motif.MotifLookAndFeel";
        }
    }
    return getCrossPlatformLookAndFeelClassName();
}
 
Example 25
Source Project: jdk8u60   Source File: MotifColorUtilities.java    License: GNU General Public License v2.0 5 votes vote down vote up
static void loadSystemColors(int[] systemColors) {
    if ("Linux".equals(AccessController.doPrivileged(new GetPropertyAction("os.name")))) { // Load motif default colors on Linux.
        loadMotifDefaultColors(systemColors);
    }
    else
    {
        try {
            loadSystemColorsForCDE(systemColors);
        }
        catch (Exception e) // Failure to load CDE colors.
        {
            loadMotifDefaultColors(systemColors);
        }
    }
}
 
Example 26
Source Project: dragonwell8_jdk   Source File: Charset.java    License: GNU General Public License v2.0 5 votes vote down vote up
static boolean atBugLevel(String bl) {              // package-private
    String level = bugLevel;
    if (level == null) {
        if (!sun.misc.VM.isBooted())
            return false;
        bugLevel = level = AccessController.doPrivileged(
            new GetPropertyAction("sun.nio.cs.bugLevel", ""));
    }
    return level.equals(bl);
}
 
Example 27
Source Project: jdk8u60   Source File: WindowsLookAndFeel.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void initialize() {
    super.initialize();

    // Set the flag which determines which version of Windows should
    // be rendered. This flag only need to be set once.
    // if version <= 4.0 then the classic LAF should be loaded.
    if (OSInfo.getWindowsVersion().compareTo(OSInfo.WINDOWS_95) <= 0) {
        isClassicWindows = true;
    } else {
        isClassicWindows = false;
        XPStyle.invalidateStyle();
    }

    // Using the fonts set by the user can potentially cause
    // performance and compatibility issues, so allow this feature
    // to be switched off either at runtime or programmatically
    //
    String systemFonts = java.security.AccessController.doPrivileged(
           new GetPropertyAction("swing.useSystemFontSettings"));
    useSystemFontSettings = (systemFonts == null ||
                             Boolean.valueOf(systemFonts).booleanValue());

    if (useSystemFontSettings) {
        Object value = UIManager.get("Application.useSystemFontSettings");

        useSystemFontSettings = (value == null ||
                                 Boolean.TRUE.equals(value));
    }
    KeyboardFocusManager.getCurrentKeyboardFocusManager().
        addKeyEventPostProcessor(WindowsRootPaneUI.altProcessor);

}
 
Example 28
/**
 * Returns the default SelectorProvider.
 */
public static SelectorProvider create() {
    String osname = AccessController
        .doPrivileged(new GetPropertyAction("os.name"));
    if (osname.equals("SunOS"))
        return createProvider("sun.nio.ch.DevPollSelectorProvider");
    if (osname.equals("Linux"))
        return createProvider("sun.nio.ch.EPollSelectorProvider");
    return new sun.nio.ch.PollSelectorProvider();
}
 
Example 29
Source Project: jdk8u_jdk   Source File: SwingUtilities.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns true if <code>setTransferHandler</code> should change the
 * <code>DropTarget</code>.
 */
private static boolean getSuppressDropTarget() {
    if (!checkedSuppressDropSupport) {
        suppressDropSupport = Boolean.valueOf(
            AccessController.doPrivileged(
                new GetPropertyAction("suppressSwingDropSupport")));
        checkedSuppressDropSupport = true;
    }
    return suppressDropSupport;
}
 
Example 30
Source Project: dragonwell8_jdk   Source File: SunToolkit.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the locale in which the runtime was started.
 */
public static Locale getStartupLocale() {
    if (startupLocale == null) {
        String language, region, country, variant;
        language = AccessController.doPrivileged(
                        new GetPropertyAction("user.language", "en"));
        // for compatibility, check for old user.region property
        region = AccessController.doPrivileged(
                        new GetPropertyAction("user.region"));
        if (region != null) {
            // region can be of form country, country_variant, or _variant
            int i = region.indexOf('_');
            if (i >= 0) {
                country = region.substring(0, i);
                variant = region.substring(i + 1);
            } else {
                country = region;
                variant = "";
            }
        } else {
            country = AccessController.doPrivileged(
                            new GetPropertyAction("user.country", ""));
            variant = AccessController.doPrivileged(
                            new GetPropertyAction("user.variant", ""));
        }
        startupLocale = new Locale(language, country, variant);
    }
    return startupLocale;
}