Search in sources :

Example 16 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class CMSManager method getModule.

public static synchronized PCMM getModule() {
    if (cmmImpl != null) {
        return cmmImpl;
    }
    CMMServiceProvider spi = AccessController.doPrivileged(new PrivilegedAction<CMMServiceProvider>() {

        public CMMServiceProvider run() {
            String cmmClass = System.getProperty("sun.java2d.cmm", "sun.java2d.cmm.lcms.LcmsServiceProvider");
            ServiceLoader<CMMServiceProvider> cmmLoader = ServiceLoader.loadInstalled(CMMServiceProvider.class);
            CMMServiceProvider spi = null;
            for (CMMServiceProvider cmm : cmmLoader) {
                spi = cmm;
                if (cmm.getClass().getName().equals(cmmClass)) {
                    break;
                }
            }
            return spi;
        }
    });
    cmmImpl = spi.getColorManagementModule();
    if (cmmImpl == null) {
        throw new CMMException("Cannot initialize Color Management System." + "No CM module found");
    }
    GetPropertyAction gpa = new GetPropertyAction("sun.java2d.cmm.trace");
    String cmmTrace = (String) AccessController.doPrivileged(gpa);
    if (cmmTrace != null) {
        cmmImpl = new CMMTracer(cmmImpl);
    }
    return cmmImpl;
}
Also used : ServiceLoader(java.util.ServiceLoader) GetPropertyAction(sun.security.action.GetPropertyAction) CMMException(java.awt.color.CMMException)

Example 17 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class Charset method defaultCharset.

/**
     * 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;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 18 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class PostEventQueue method needsXEmbed.

/**
     * Returns whether default toolkit needs the support of the xembed
     * from embedding host(if any).
     * @return <code>true</code>, if XEmbed is needed, <code>false</code> otherwise
     */
public static boolean needsXEmbed() {
    String noxembed = AccessController.doPrivileged(new GetPropertyAction("sun.awt.noxembed", "false"));
    if ("true".equals(noxembed)) {
        return false;
    }
    Toolkit tk = Toolkit.getDefaultToolkit();
    if (tk instanceof SunToolkit) {
        // concrete behavior
        return ((SunToolkit) tk).needsXEmbedImpl();
    } else {
        // Non-SunToolkit doubtly might support XEmbed
        return false;
    }
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Example 19 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class ProviderFactory method getDefaultFactory.

/**
     * Returns an implementation of a {@code ProviderFactory} which
     * creates instances of Providers.
     *
     * The created Provider instances will be linked to all appropriate
     * and enabled system-defined tracing mechanisms in the JDK.
     *
     * @return a {@code ProviderFactory} that is used to create Providers.
     */
public static ProviderFactory getDefaultFactory() {
    HashSet<ProviderFactory> factories = new HashSet<ProviderFactory>();
    // Try to instantiate a DTraceProviderFactory
    String prop = AccessController.doPrivileged(new GetPropertyAction("com.sun.tracing.dtrace"));
    if ((prop == null || !prop.equals("disable")) && DTraceProviderFactory.isSupported()) {
        factories.add(new DTraceProviderFactory());
    }
    // Try to instantiate an output stream factory
    prop = AccessController.doPrivileged(new GetPropertyAction("sun.tracing.stream"));
    if (prop != null) {
        for (String spec : prop.split(",")) {
            PrintStream ps = getPrintStreamFromSpec(spec);
            if (ps != null) {
                factories.add(new PrintStreamProviderFactory(ps));
            }
        }
    }
    // factory that encapsulates that.
    if (factories.size() == 0) {
        return new NullProviderFactory();
    } else if (factories.size() == 1) {
        return factories.toArray(new ProviderFactory[1])[0];
    } else {
        return new MultiplexProviderFactory(factories);
    }
}
Also used : PrintStream(java.io.PrintStream) GetPropertyAction(sun.security.action.GetPropertyAction) DTraceProviderFactory(sun.tracing.dtrace.DTraceProviderFactory) PrintStreamProviderFactory(sun.tracing.PrintStreamProviderFactory) NullProviderFactory(sun.tracing.NullProviderFactory) PrintStreamProviderFactory(sun.tracing.PrintStreamProviderFactory) MultiplexProviderFactory(sun.tracing.MultiplexProviderFactory) DTraceProviderFactory(sun.tracing.dtrace.DTraceProviderFactory) NullProviderFactory(sun.tracing.NullProviderFactory) MultiplexProviderFactory(sun.tracing.MultiplexProviderFactory) HashSet(java.util.HashSet)

Example 20 with GetPropertyAction

use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.

the class MetalLookAndFeel method getCurrentTheme.

/**
     * Return the theme currently being used by <code>MetalLookAndFeel</code>.
     * If the current theme is {@code null}, the default theme is created.
     *
     * @return the current theme
     * @see #setCurrentTheme
     * @since 1.5
     */
public static MetalTheme getCurrentTheme() {
    MetalTheme currentTheme;
    AppContext context = AppContext.getAppContext();
    currentTheme = (MetalTheme) context.get("currentMetalTheme");
    if (currentTheme == null) {
        //   Theme here.
        if (useHighContrastTheme()) {
            currentTheme = new MetalHighContrastTheme();
        } else {
            // Create the default theme. We prefer Ocean, but will
            // use DefaultMetalTheme if told to.
            String theme = AccessController.doPrivileged(new GetPropertyAction("swing.metalTheme"));
            if ("steel".equals(theme)) {
                currentTheme = new DefaultMetalTheme();
            } else {
                currentTheme = new OceanTheme();
            }
        }
        setCurrentTheme(currentTheme);
    }
    return currentTheme;
}
Also used : GetPropertyAction(sun.security.action.GetPropertyAction)

Aggregations

GetPropertyAction (sun.security.action.GetPropertyAction)26 IOException (java.io.IOException)2 PrintStream (java.io.PrintStream)2 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Graphics (java.awt.Graphics)1 Rectangle (java.awt.Rectangle)1 Toolkit (java.awt.Toolkit)1 CMMException (java.awt.color.CMMException)1 ContainerEvent (java.awt.event.ContainerEvent)1 ContainerListener (java.awt.event.ContainerListener)1 File (java.io.File)1 FileOutputStream (java.io.FileOutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 InetSocketAddress (java.net.InetSocketAddress)1 Proxy (java.net.Proxy)1 ProxySelector (java.net.ProxySelector)1 ServerSocket (java.net.ServerSocket)1 SocketException (java.net.SocketException)1 URI (java.net.URI)1