本文整理汇总了Java中sun.misc.SharedSecrets.setJavaAWTAccess方法的典型用法代码示例。如果您正苦于以下问题:Java SharedSecrets.setJavaAWTAccess方法的具体用法?Java SharedSecrets.setJavaAWTAccess怎么用?Java SharedSecrets.setJavaAWTAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.misc.SharedSecrets
的用法示例。
在下文中一共展示了SharedSecrets.setJavaAWTAccess方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import sun.misc.SharedSecrets; //导入方法依赖的package包/类
public static void init() {
SharedSecrets.setJavaAWTAccess(javaAwtAccess);
if (System.getProperty("test.security", "on").equals("on")) {
Policy p = new SimplePolicy(new LoggingPermission("control", null),
new RuntimePermission("setContextClassLoader"),
new RuntimePermission("shutdownHooks"));
Policy.setPolicy(p);
System.setSecurityManager(new SecurityManager());
}
}
示例2: main
import sun.misc.SharedSecrets; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
System.setProperty(CONFIG_FILE_KEY,
new File(System.getProperty("test.src", "."),
"rootlogger.properties").getAbsolutePath());
System.out.println(CONFIG_FILE_KEY + "="
+ System.getProperty(CONFIG_FILE_KEY));
if (! new File(System.getProperty(CONFIG_FILE_KEY)).canRead()) {
throw new RuntimeException("can't read config file: "
+ System.getProperty(CONFIG_FILE_KEY));
}
final String configFile = System.getProperty(CONFIG_FILE_KEY);
test("no security");
LogManager.getLogManager().readConfiguration();
Policy.setPolicy(new SimplePolicy(configFile));
System.setSecurityManager(new SecurityManager());
test("security");
LogManager.getLogManager().readConfiguration();
final JavaAWTAccessStub access = new JavaAWTAccessStub();
SharedSecrets.setJavaAWTAccess(access);
test("security and no context");
for (Context ctx : Context.values()) {
LogManager.getLogManager().readConfiguration();
access.setContext(ctx);
test("security and context " + ctx);
}
}
示例3: main
import sun.misc.SharedSecrets; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
final String testCase = args.length == 0 ? "getLogger" : args[0];
final JavaAWTAccessStub access = new JavaAWTAccessStub();
SharedSecrets.setJavaAWTAccess(access);
final ThreadGroup tg = new ThreadGroup("TestGroup");
Thread t = new Thread(tg, "test") {
public void run() {
try {
access.setContext(Context.ONE);
final PrintStream out = System.out;
System.setOut(null);
try {
if ("getLogger".equals(testCase)) {
Logger.getLogger("sun.plugin");
} else {
LogManager.getLogManager();
}
} finally {
System.setOut(out);
}
System.out.println(Logger.global);
} catch (Throwable x) {
x.printStackTrace();
thrown = x;
}
}
};
Policy.setPolicy(new Policy() {
public boolean implies(ProtectionDomain domain,
Permission permission) {
return true; // all permissions
}
});
System.setSecurityManager(new SecurityManager());
t.start();
t.join();
if (thrown == null) {
System.out.println("PASSED: " + testCase);
} else {
System.err.println("FAILED: " + testCase);
throw new Error("Test failed: " + testCase + " - " + thrown, thrown);
}
}