private static PermissionFactory<?> permissionFactory() { Class<?> c = AccessController .doPrivileged(new PrivilegedAction<Class<?>>() { public Class<?> run() { try { return Class.forName(AWTFactory, true, null); } catch (ClassNotFoundException e) { // not available return null; } }}); if (c != null) { // AWT present try { return (PermissionFactory<?>)c.newInstance(); } catch (InstantiationException x) { throw new InternalError(x.getMessage()); } catch (IllegalAccessException x) { throw new InternalError(x.getMessage()); } } else { // AWT not present return new FakeAWTPermissionFactory(); } }