private Object getInstanceSafely() { final ClassLoader cl = WildFlySecurityManager.getCurrentContextClassLoaderPrivileged(); try { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged( factory.getClass().getClassLoader()); return factory.getValidator(); } finally { WildFlySecurityManager.setCurrentContextClassLoaderPrivileged(cl); } }