use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class TimeZone method setDefaultZone.
private static synchronized TimeZone setDefaultZone() {
TimeZone tz;
// get the time zone ID from the system properties
String zoneID = AccessController.doPrivileged(new GetPropertyAction("user.timezone"));
// platform to Java time zone ID mapping.
if (zoneID == null || zoneID.isEmpty()) {
String javaHome = AccessController.doPrivileged(new GetPropertyAction("java.home"));
try {
zoneID = getSystemTimeZoneID(javaHome);
if (zoneID == null) {
zoneID = GMT_ID;
}
} catch (NullPointerException e) {
zoneID = GMT_ID;
}
}
// Get the time zone for zoneID. But not fall back to
// "GMT" here.
tz = getTimeZone(zoneID, false);
if (tz == null) {
// If the given zone ID is unknown in Java, try to
// get the GMT-offset-based time zone ID,
// a.k.a. custom time zone ID (e.g., "GMT-08:00").
String gmtOffsetID = getSystemGMTOffsetID();
if (gmtOffsetID != null) {
zoneID = gmtOffsetID;
}
tz = getTimeZone(zoneID, true);
}
assert tz != null;
final String id = zoneID;
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override
public Void run() {
System.setProperty("user.timezone", id);
return null;
}
});
defaultTimeZone = tz;
return tz;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class SwingUtilities method getSuppressDropTarget.
/**
* 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;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class MetalLookAndFeel method isWindows.
/**
* Returns true if running on Windows.
*/
static boolean isWindows() {
if (!checkedWindows) {
OSInfo.OSType osType = AccessController.doPrivileged(OSInfo.getOSTypeAction());
if (osType == OSInfo.OSType.WINDOWS) {
isWindows = true;
String systemFonts = AccessController.doPrivileged(new GetPropertyAction("swing.useSystemFontSettings"));
useSystemFonts = (systemFonts != null && (Boolean.valueOf(systemFonts).booleanValue()));
}
checkedWindows = true;
}
return isWindows;
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class SunGraphicsEnvironment method getScaleFactor.
public static double getScaleFactor(String propertyName) {
String scaleFactor = AccessController.doPrivileged(new GetPropertyAction(propertyName, "-1"));
if (scaleFactor == null || scaleFactor.equals("-1")) {
return -1;
}
try {
double units = 1.0;
if (scaleFactor.endsWith("x")) {
scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
} else if (scaleFactor.endsWith("dpi")) {
units = 96;
scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 3);
} else if (scaleFactor.endsWith("%")) {
units = 100;
scaleFactor = scaleFactor.substring(0, scaleFactor.length() - 1);
}
double scale = Double.parseDouble(scaleFactor);
return scale <= 0 ? -1 : scale / units;
} catch (NumberFormatException ignored) {
return -1;
}
}
use of sun.security.action.GetPropertyAction in project jdk8u_jdk by JetBrains.
the class JRSUIUtils method currentMacOSXVersionMatchesGivenVersionRange.
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;
}
Aggregations