/[classpath]/classpath/java/lang/Runtime.java
ViewVC logotype

Diff of /classpath/java/lang/Runtime.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.8 by glavaux, Fri Jul 30 09:32:32 2004 UTC revision 1.8.2.1 by gnu_andrew, Fri Jan 14 10:24:15 2005 UTC
# Line 664  public class Runtime Line 664  public class Runtime
664     */     */
665    public void load(String filename)    public void load(String filename)
666    {    {
667        SecurityManager sm = securityManager; // Be thread-safe!
668        if (sm != null)
669          sm.checkLink(filename);
670      if (loadLib(filename) == 0)      if (loadLib(filename) == 0)
671        throw new UnsatisfiedLinkError("Could not load library " + filename);        throw new UnsatisfiedLinkError("Could not load library " + filename);
672    }    }
673    
674    // Private version of load(String) that doesn't throw Exception on    /**
675    // load error, but it does do security checks (which can throw     * Do a security check on the filename and then load the native library.
676    // SecurityExceptions). Convenience method for early bootstrap     *
677    // process.     * @param filename the file to load
678    private int loadLib(String filename)     * @return 0 on failure, nonzero on success
679       * @throws SecurityException if file read permission is denied
680       */
681      private static int loadLib(String filename)
682    {    {
683      SecurityManager sm = securityManager; // Be thread-safe!      SecurityManager sm = securityManager; // Be thread-safe!
684      if (sm != null)      if (sm != null)
685        sm.checkLink(filename);        sm.checkRead(filename);
686      return VMRuntime.nativeLoad(filename);      return VMRuntime.nativeLoad(filename);
687    }    }
688    
# Line 702  public class Runtime Line 708  public class Runtime
708     */     */
709    public void loadLibrary(String libname)    public void loadLibrary(String libname)
710    {    {
711        SecurityManager sm = securityManager; // Be thread-safe!
712        if (sm != null)
713          sm.checkLink(libname);
714    
715      String filename;      String filename;
716      ClassLoader cl = VMSecurityManager.currentClassLoader();      ClassLoader cl = VMSecurityManager.currentClassLoader();
717      if (cl != null)      if (cl != null)
# Line 709  public class Runtime Line 719  public class Runtime
719          filename = cl.findLibrary(libname);          filename = cl.findLibrary(libname);
720          if (filename != null)          if (filename != null)
721            {            {
             // Use loadLib so no UnsatisfiedLinkError are thrown.  
722              if (loadLib(filename) != 0)              if (loadLib(filename) != 0)
723                return;                return;
724                else
725                  throw new UnsatisfiedLinkError("Could not load library " + filename);
726            }            }
727        }        }
728    
729      filename = System.mapLibraryName(libname);      filename = System.mapLibraryName(libname);
730      for (int i = 0; i < libpath.length; i++)      for (int i = 0; i < libpath.length; i++)
       // Use loadLib so no UnsatisfiedLinkError are thrown.  
731        if (loadLib(libpath[i] + filename) != 0)        if (loadLib(libpath[i] + filename) != 0)
732          return;          return;
733    

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.8.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26