7145798: System.loadLibrary does not search current working directory

Fri, 17 Feb 2012 15:55:27 -0800

author
dcubed
date
Fri, 17 Feb 2012 15:55:27 -0800
changeset 3586
86ce3208eb18
parent 3562
df4927a3b82e
child 3587
0368109684cb

7145798: System.loadLibrary does not search current working directory
Summary: Append "." to java.library.path on MacOS X to ease migration from Apple's Java6 to OpenJDK7.
Reviewed-by: phh, jmelvin, coleenp

src/os/bsd/vm/os_bsd.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/os/bsd/vm/os_bsd.cpp	Thu Feb 16 17:19:40 2012 -0500
     1.2 +++ b/src/os/bsd/vm/os_bsd.cpp	Fri Feb 17 15:55:27 2012 -0800
     1.3 @@ -568,6 +568,25 @@
     1.4              sprintf(ld_library_path, "%s:%s", v, t);
     1.5              free(t);
     1.6          }
     1.7 +
     1.8 +#ifdef __APPLE__
     1.9 +        // Apple's Java6 has "." at the beginning of java.library.path.
    1.10 +        // OpenJDK on Windows has "." at the end of java.library.path.
    1.11 +        // OpenJDK on Linux and Solaris don't have "." in java.library.path
    1.12 +        // at all. To ease the transition from Apple's Java6 to OpenJDK7,
    1.13 +        // "." is appended to the end of java.library.path. Yes, this
    1.14 +        // could cause a change in behavior, but Apple's Java6 behavior
    1.15 +        // can be achieved by putting "." at the beginning of the
    1.16 +        // JAVA_LIBRARY_PATH environment variable.
    1.17 +        {
    1.18 +            char *t = ld_library_path;
    1.19 +            // that's +3 for appending ":." and the trailing '\0'
    1.20 +            ld_library_path = (char *) malloc(strlen(t) + 3);
    1.21 +            sprintf(ld_library_path, "%s:%s", t, ".");
    1.22 +            free(t);
    1.23 +        }
    1.24 +#endif
    1.25 +
    1.26          Arguments::set_library_path(ld_library_path);
    1.27      }
    1.28  

mercurial