Java Code Examples for sun.security.action.GetPropertyAction#privilegedGetProperties()

The following examples show how to use sun.security.action.GetPropertyAction#privilegedGetProperties() . 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 File: Locale.java    From openjdk-jdk9 with 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 2
Source File: Locale.java    From Bytecoder with Apache License 2.0 5 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,
            getDefaultExtensions(props.getProperty("user.extensions", ""))
                .orElse(null));
}
 
Example 3
Source File: Locale.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
private static Locale initDefault(Locale.Category category) {
    Properties props = GetPropertyAction.privilegedGetProperties();

    return getInstance(
        props.getProperty(category.languageKey,
                defaultLocale.getLanguage()),
        props.getProperty(category.scriptKey,
                defaultLocale.getScript()),
        props.getProperty(category.countryKey,
                defaultLocale.getCountry()),
        props.getProperty(category.variantKey,
                defaultLocale.getVariant()),
        getDefaultExtensions(props.getProperty(category.extensionsKey, ""))
            .orElse(defaultLocale.getLocaleExtensions()));
}
 
Example 4
Source File: ReflectionFactory.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/** We have to defer full initialization of this class until after
    the static initializer is run since java.lang.reflect.Method's
    static initializer (more properly, that for
    java.lang.reflect.AccessibleObject) causes this class's to be
    run, before the system properties are set up. */
private static void checkInitted() {
    if (initted) return;

    // Defer initialization until module system is initialized so as
    // to avoid inflation and spinning bytecode in unnamed modules
    // during early startup.
    if (!VM.isModuleSystemInited()) {
        return;
    }

    Properties props = GetPropertyAction.privilegedGetProperties();
    String val = props.getProperty("sun.reflect.noInflation");
    if (val != null && val.equals("true")) {
        noInflation = true;
    }

    val = props.getProperty("sun.reflect.inflationThreshold");
    if (val != null) {
        try {
            inflationThreshold = Integer.parseInt(val);
        } catch (NumberFormatException e) {
            throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
        }
    }

    disableSerialConstructorChecks =
        "true".equals(props.getProperty("jdk.disableSerialConstructorChecks"));

    initted = true;
}
 
Example 5
Source File: Locale.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static Locale initDefault(Locale.Category category) {
    Properties props = GetPropertyAction.privilegedGetProperties();
    return getInstance(
        props.getProperty(category.languageKey,
                defaultLocale.getLanguage()),
        props.getProperty(category.scriptKey,
                defaultLocale.getScript()),
        props.getProperty(category.countryKey,
                defaultLocale.getCountry()),
        props.getProperty(category.variantKey,
                defaultLocale.getVariant()),
        null);
}
 
Example 6
Source File: ReflectionFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/** We have to defer full initialization of this class until after
    the static initializer is run since java.lang.reflect.Method's
    static initializer (more properly, that for
    java.lang.reflect.AccessibleObject) causes this class's to be
    run, before the system properties are set up. */
private static void checkInitted() {
    if (initted) return;

    // Defer initialization until module system is initialized so as
    // to avoid inflation and spinning bytecode in unnamed modules
    // during early startup.
    if (!VM.isModuleSystemInited()) {
        return;
    }

    Properties props = GetPropertyAction.privilegedGetProperties();
    String val = props.getProperty("sun.reflect.noInflation");
    if (val != null && val.equals("true")) {
        noInflation = true;
    }

    val = props.getProperty("sun.reflect.inflationThreshold");
    if (val != null) {
        try {
            inflationThreshold = Integer.parseInt(val);
        } catch (NumberFormatException e) {
            throw new RuntimeException("Unable to parse property sun.reflect.inflationThreshold", e);
        }
    }

    initted = true;
}
 
Example 7
Source File: ProcessImpl.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
String helperPath() {
    Properties props = GetPropertyAction.privilegedGetProperties();
    return helperPath(props.getProperty("java.home"),
                      props.getProperty("os.arch"));
}
 
Example 8
Source File: UnixFileSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public UnixFileSystem() {
    Properties props = GetPropertyAction.privilegedGetProperties();
    slash = props.getProperty("file.separator").charAt(0);
    colon = props.getProperty("path.separator").charAt(0);
    javaHome = props.getProperty("java.home");
}
 
Example 9
Source File: WinNTFileSystem.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public WinNTFileSystem() {
    Properties props = GetPropertyAction.privilegedGetProperties();
    slash = props.getProperty("file.separator").charAt(0);
    semicolon = props.getProperty("path.separator").charAt(0);
    altSlash = (this.slash == '\\') ? '/' : '\\';
}