use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class RenderingEngine method getInstance.
/**
* Returns an instance of {@code RenderingEngine} as determined
* by the installation environment and runtime flags.
* <p>
* A specific instance of the {@code RenderingEngine} can be
* chosen by specifying the runtime flag:
* <pre>
* java -Dsun.java2d.renderer=<classname>
* </pre>
*
* If no specific {@code RenderingEngine} is specified on the command
* or Ductus renderer is specified, it will attempt loading the
* sun.dc.DuctusRenderingEngine class using Class.forName as a fastpath;
* if not found, use the ServiceLoader.
* If no specific {@code RenderingEngine} is specified on the command
* line then the last one returned by enumerating all subclasses of
* {@code RenderingEngine} known to the ServiceLoader is used.
* <p>
* Runtime tracing of the actions of the {@code RenderingEngine}
* can be enabled by specifying the runtime flag:
* <pre>
* java -Dsun.java2d.renderer.trace=<any string>
* </pre>
* @return an instance of {@code RenderingEngine}
* @since 1.7
*/
public static synchronized RenderingEngine getInstance() {
if (reImpl != null) {
return reImpl;
}
reImpl = AccessController.doPrivileged(new PrivilegedAction<RenderingEngine>() {
public RenderingEngine run() {
final String ductusREClass = "sun.dc.DuctusRenderingEngine";
String reClass = System.getProperty("sun.java2d.renderer", ductusREClass);
try {
Class<?> cls = Class.forName(reClass);
return (RenderingEngine) cls.newInstance();
} catch (ReflectiveOperationException ignored) {
// not found
}
ServiceLoader<RenderingEngine> reLoader = ServiceLoader.loadInstalled(RenderingEngine.class);
RenderingEngine service = null;
for (RenderingEngine re : reLoader) {
service = re;
if (re.getClass().getName().equals(reClass)) {
break;
}
}
return service;
}
});
if (reImpl == null) {
throw new InternalError("No RenderingEngine module found");
}
GetPropertyAction gpa = new GetPropertyAction("sun.java2d.renderer.trace");
String reTrace = AccessController.doPrivileged(gpa);
if (reTrace != null) {
reImpl = new Tracer(reImpl);
}
return reImpl;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class ExtendedCharsets method init.
// If the sun.nio.cs.map property is defined on the command line we won't
// see it in the system-properties table until after the charset subsystem
// has been initialized. We therefore delay the effect of this property
// until after the JRE has completely booted.
//
// At the moment following values for this property are supported, property
// value string is case insensitive.
//
// (1)"Windows-31J/Shift_JIS"
// In 1.4.1 we added a correct implementation of the Shift_JIS charset
// but in previous releases this charset name had been treated as an alias
// for Windows-31J, aka MS932. Users who have existing code that depends
// upon this alias can restore the previous behavior by defining this
// property to have this value.
//
// (2)"x-windows-50221/ISO-2022-JP"
// "x-windows-50220/ISO-2022-JP"
// "x-windows-iso2022jp/ISO-2022-JP"
// The charset ISO-2022-JP is a "standard based" implementation by default,
// which supports ASCII, JIS_X_0201 and JIS_X_0208 mappings based encoding
// and decoding only.
// There are three Microsoft iso-2022-jp variants, namely x-windows-50220,
// x-windows-50221 and x-windows-iso2022jp which behaves "slightly" differently
// compared to the "standard based" implementation. See ISO2022_JP.java for
// detailed description. Users who prefer the behavior of MS iso-2022-jp
// variants should use these names explicitly instead of using "ISO-2022-JP"
// and its aliases. However for those who need the ISO-2022-JP charset behaves
// exactly the same as MS variants do, above properties can be defined to
// switch.
//
// If we need to define other charset-alias mappings in the future then
// this property could be further extended, the general idea being that its
// value should be of the form
//
// new-charset-1/old-charset-1,new-charset-2/old-charset-2,...
//
// where each charset named to the left of a slash is intended to replace
// (most) uses of the charset named to the right of the slash.
//
protected void init() {
if (initialized)
return;
if (!sun.misc.VM.isBooted())
return;
String map = AccessController.doPrivileged(new GetPropertyAction("sun.nio.cs.map"));
boolean sjisIsMS932 = false;
boolean iso2022jpIsMS50221 = false;
boolean iso2022jpIsMS50220 = false;
boolean iso2022jpIsMSISO2022JP = false;
if (map != null) {
String[] maps = map.split(",");
for (int i = 0; i < maps.length; i++) {
if (maps[i].equalsIgnoreCase("Windows-31J/Shift_JIS")) {
sjisIsMS932 = true;
} else if (maps[i].equalsIgnoreCase("x-windows-50221/ISO-2022-JP")) {
iso2022jpIsMS50221 = true;
} else if (maps[i].equalsIgnoreCase("x-windows-50220/ISO-2022-JP")) {
iso2022jpIsMS50220 = true;
} else if (maps[i].equalsIgnoreCase("x-windows-iso2022jp/ISO-2022-JP")) {
iso2022jpIsMSISO2022JP = true;
}
}
}
if (sjisIsMS932) {
deleteCharset("Shift_JIS", new String[] { // historical
"sjis", "shift_jis", "shift-jis", "ms_kanji", "x-sjis", "csShiftJIS" });
deleteCharset("windows-31j", new String[] { // JDK historical
"MS932", "windows-932", "csWindows31J" });
charset("Shift_JIS", "SJIS", new String[] { // JDK historical
"sjis" });
charset("windows-31j", "MS932", new String[] { // JDK historical
"MS932", "windows-932", "csWindows31J", "shift-jis", "ms_kanji", "x-sjis", "csShiftJIS", // resolved first, before looking up canonical names.
"shift_jis" });
}
if (iso2022jpIsMS50221 || iso2022jpIsMS50220 || iso2022jpIsMSISO2022JP) {
deleteCharset("ISO-2022-JP", new String[] { "iso2022jp", "jis", "csISO2022JP", "jis_encoding", "csjisencoding" });
if (iso2022jpIsMS50221) {
deleteCharset("x-windows-50221", new String[] { "cp50221", "ms50221" });
charset("x-windows-50221", "MS50221", new String[] { "cp50221", "ms50221", "iso-2022-jp", "iso2022jp", "jis", "csISO2022JP", "jis_encoding", "csjisencoding" });
} else if (iso2022jpIsMS50220) {
deleteCharset("x-windows-50220", new String[] { "cp50220", "ms50220" });
charset("x-windows-50220", "MS50220", new String[] { "cp50220", "ms50220", "iso-2022-jp", "iso2022jp", "jis", "csISO2022JP", "jis_encoding", "csjisencoding" });
} else {
deleteCharset("x-windows-iso2022jp", new String[] { "windows-iso2022jp" });
charset("x-windows-iso2022jp", "MSISO2022JP", new String[] { "windows-iso2022jp", "iso-2022-jp", "iso2022jp", "jis", "csISO2022JP", "jis_encoding", "csjisencoding" });
}
}
String osName = AccessController.doPrivileged(new GetPropertyAction("os.name"));
if ("SunOS".equals(osName) || "Linux".equals(osName) || "AIX".equals(osName) || osName.contains("OS X")) {
charset("x-COMPOUND_TEXT", "COMPOUND_TEXT", new String[] { // JDK historical
"COMPOUND_TEXT", "x11-compound_text", "x-compound-text" });
}
initialized = true;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class FileChannelImpl method isSharedFileLockTable.
// The lock list in J2SE 1.4/5.0 was local to each FileChannel instance so
// the overlap check wasn't system wide when there were multiple channels to
// the same file. This property is used to get 1.4/5.0 behavior if desired.
private static boolean isSharedFileLockTable() {
if (!propertyChecked) {
synchronized (FileChannelImpl.class) {
if (!propertyChecked) {
String value = AccessController.doPrivileged(new GetPropertyAction("sun.nio.ch.disableSystemWideOverlappingFileLockCheck"));
isSharedFileLockTable = ((value == null) || value.equals("false"));
propertyChecked = true;
}
}
}
return isSharedFileLockTable;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class UIManager method getSystemLookAndFeelClassName.
/**
* 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();
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class MarlinProperties method getInteger.
static int getInteger(final String key, final int def, final int min, final int max) {
final String property = AccessController.doPrivileged(new GetPropertyAction(key));
int value = def;
if (property != null) {
try {
value = Integer.decode(property);
} catch (NumberFormatException e) {
logInfo("Invalid integer value for " + key + " = " + property);
}
}
// check for invalid values
if ((value < min) || (value > max)) {
logInfo("Invalid value for " + key + " = " + value + "; expected value in range[" + min + ", " + max + "] !");
value = def;
}
return value;
}
Aggregations