Java Code Examples for sun.misc.JavaAWTAccess#isMainAppContext()
The following examples show how to use
sun.misc.JavaAWTAccess#isMainAppContext() .
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: TimeZone.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
/** * Returns the default TimeZone in an AppContext if any AppContext * has ever used. null is returned if any AppContext hasn't been * used or if the AppContext doesn't have the default TimeZone. * null is also returned if allowSetDefault is false. * * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't * been loaded. If so, it implies that AWTSecurityManager is not our * SecurityManager and we can use a local static variable. * This works around a build time issue. */ private static TimeZone getDefaultInAppContext() { if (allowSetDefault) { // JavaAWTAccess provides access implementation-private methods without using reflection. JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); if (System.getSecurityManager() == null || javaAWTAccess == null) { return mainAppContextDefault; } else if (javaAWTAccess.isDisposed()) { return null; } else { TimeZone tz = (TimeZone) javaAWTAccess.get(TimeZone.class); if (tz == null && javaAWTAccess.isMainAppContext()) { return mainAppContextDefault; } else { return tz; } } } return null; }
Example 2
Source File: TimeZone.java From jdk-1.7-annotated with Apache License 2.0 | 5 votes |
/** * Sets the default TimeZone in the AppContext to the given tz if * allowSetDefault is true. null is handled special: do nothing if any * AppContext hasn't been used, remove the default TimeZone in the * AppContext otherwise. * * Note that javaAWTAccess may be null if sun.awt.AppContext class hasn't * been loaded. If so, it implies that AWTSecurityManager is not our * SecurityManager and we can use a local static variable. * This works around a build time issue. */ private static void setDefaultInAppContext(TimeZone tz) { if (allowSetDefault) { // JavaAWTAccess provides access implementation-private methods without using reflection. JavaAWTAccess javaAWTAccess = SharedSecrets.getJavaAWTAccess(); if (System.getSecurityManager() == null || javaAWTAccess == null) { mainAppContextDefault = tz; } else if (!javaAWTAccess.isDisposed()) { javaAWTAccess.put(TimeZone.class, tz); if (javaAWTAccess.isMainAppContext()) { mainAppContextDefault = null; } } } }