diff --git a/jdk/src/share/classes/java/lang/ClassLoader.java b/jdk/src/share/classes/java/lang/ClassLoader.java index 876b1855012..1652d6cc4eb 100644 --- a/jdk/src/share/classes/java/lang/ClassLoader.java +++ b/jdk/src/share/classes/java/lang/ClassLoader.java @@ -1859,18 +1859,17 @@ public abstract class ClassLoader { String name = NativeLibrary.findBuiltinLib(file.getName()); boolean isBuiltin = (name != null); if (!isBuiltin) { - boolean exists = AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - return file.exists() ? Boolean.TRUE : null; - }}) - != null; - if (!exists) { - return false; - } - try { - name = file.getCanonicalPath(); - } catch (IOException e) { + name = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { + try { + return file.exists() ? file.getCanonicalPath() : null; + } catch (IOException e) { + return null; + } + } + }); + if (name == null) { return false; } } diff --git a/jdk/src/share/classes/sun/misc/Launcher.java b/jdk/src/share/classes/sun/misc/Launcher.java index 89557f711b4..75310f5aa0e 100644 --- a/jdk/src/share/classes/sun/misc/Launcher.java +++ b/jdk/src/share/classes/sun/misc/Launcher.java @@ -207,7 +207,7 @@ public class Launcher { * look in the extension directory itself. */ public String findLibrary(String name) { - name = System.mapLibraryName(name); + final String libname = System.mapLibraryName(name); URL[] urls = super.getURLs(); File prevDir = null; for (int i = 0; i < urls.length; i++) { @@ -216,17 +216,26 @@ public class Launcher { if (dir != null && !dir.equals(prevDir)) { // Look in architecture-specific subdirectory first // Read from the saved system properties to avoid deadlock - String arch = VM.getSavedProperty("os.arch"); - if (arch != null) { - File file = new File(new File(dir, arch), name); - if (file.exists()) { - return file.getAbsolutePath(); - } - } - // Then check the extension directory - File file = new File(dir, name); - if (file.exists()) { - return file.getAbsolutePath(); + final String arch = VM.getSavedProperty("os.arch"); + String pathname = AccessController.doPrivileged( + new PrivilegedAction() { + public String run() { + if (arch != null) { + File file = new File(new File(dir, arch), libname); + if (file.exists()) { + return file.getAbsolutePath(); + } + } + // Then check the extension directory + File file = new File(dir, libname); + if (file.exists()) { + return file.getAbsolutePath(); + } + return null; + } + }); + if (pathname != null) { + return pathname; } } prevDir = dir;