private static ClassLoader getClassLoader(final Class clazz) { if (System.getSecurityManager() == null) return clazz.getClassLoader(); return (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return clazz.getClassLoader(); } }); }
/** * Returns the absolute path name of a native library. * * @param name the library name * @return the absolute path of the native library or null if not found */ public String findLibrary(final String name) { if (System.getSecurityManager() == null) return findLocalLibrary(name); return (String) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return findLocalLibrary(name); } }); }
private ClassLoader getParentPrivileged(final BundleClassLoader bcl) { if (System.getSecurityManager() == null) return bcl.getParent(); return (ClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return bcl.getParent(); } }); }
private BundleClassLoader createBCLPrevileged( final BundleProtectionDomain pd, final String[] cp) { // Create the classloader as previleged code if security manager is present. if (System.getSecurityManager() == null) return createBCL(pd, cp); return (BundleClassLoader) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return createBCL(pd, cp); } }); }