classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cp-patches] Native library class loader fixes


From: Jeroen Frijters
Subject: RE: [cp-patches] Native library class loader fixes
Date: Tue, 4 Jan 2005 16:22:27 +0100

Archie Cobbs wrote:
> Jeroen Frijters wrote:
> > I made one change to your patch (in loadLibrary in Runtime.java):
> > +    else
> > +      {
> > +   filename = VMRuntime.mapLibraryName(libname);
> > +   for (int i = 0; i < libpath.length; i++)
> > +     if (loadLib(libpath[i] + filename, null) != 0)
> > +       return;
> > +      }
> > 
> > I think the second argument to loadLib() should be "loader" 
> instead of
> > null. It's a bit counterintuitive, but my understanding is 
> that a native
> > library always gets associated with the class loader of the 
> class that
> > called loadLibrary (regardless of whether the class loader 
> was otherwise
> > involved in finding/loading the library).
> 
> You're right.. but in this "else" block it is known that 
> loader == null, so the effect is the same either way.

Uh, oh yeah. I was going by my understanding of what the code should do
instead of by what it actually does. It's broken, it should always try
the libpath if findLibrary() returns null. Something like:

if (loader != null)
  {
    filename = loader.findLibrary(libname);
    if (filename != null)
      {
        if (loadLib(filename, loader) != 0)
          return;
        else
          throw new UnsatisfiedLinkError("Could not find library " +
filename);
      }
  }
filename = VMRuntime.mapLibraryName(libname);
for (int i = 0; i < libpath.length; i++)
  if (loadLib(libpath[i] + filename, loader) != 0)
    return;
throw new UnsatisfiedLinkError("Could not find library " + libname);

Regards,
Jeroen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]