See discussion mailing list for further info.
2005-03-14 Robert Schuster <[EMAIL PROTECTED]>
* java/lang/Runtime.java: Added support for gnu.classpath.boot.library.path system property.
cu Robert
Index: java/lang/Runtime.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/lang/Runtime.java,v retrieving revision 1.19 diff -u -r1.19 Runtime.java --- java/lang/Runtime.java 16 Feb 2005 11:18:37 -0000 1.19 +++ java/lang/Runtime.java 15 Mar 2005 01:44:01 -0000 @@ -1,5 +1,5 @@ /* Runtime.java -- access to the VM process - Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation + Copyright (C) 1998, 2002, 2003, 2004, 2005 Free Software Foundation This file is part of GNU Classpath. @@ -93,18 +93,39 @@ { if (current != null) throw new InternalError("Attempt to recreate Runtime"); + + // If used by underlying VM this contains the directories where Classpath's own + // native libraries are located. + String bootPath = SystemProperties.getProperty("gnu.classpath.boot.library.path", ""); + + // If properly set by the user this contains the directories where the application's + // native libraries are located. String path = SystemProperties.getProperty("java.library.path", "."); String pathSep = SystemProperties.getProperty("path.separator", ":"); String fileSep = SystemProperties.getProperty("file.separator", "/"); - StringTokenizer t = new StringTokenizer(path, pathSep); - libpath = new String[t.countTokens()]; - for (int i = 0; i < libpath.length; i++) - { - String prefix = t.nextToken(); - if (! prefix.endsWith(fileSep)) - prefix += fileSep; - libpath[i] = prefix; - } + + StringTokenizer t1 = new StringTokenizer(bootPath, pathSep); + StringTokenizer t2 = new StringTokenizer(path, pathSep); + libpath = new String[t1.countTokens() + t2.countTokens()]; + + int i = 0; + while(t1.hasMoreTokens()) { + String prefix = t1.nextToken(); + if (! prefix.endsWith(fileSep)) + prefix += fileSep; + + libpath[i] = prefix; + i++; + } + + while(t2.hasMoreTokens()) { + String prefix = t2.nextToken(); + if (! prefix.endsWith(fileSep)) + prefix += fileSep; + + libpath[i] = prefix; + i++; + } } /** @@ -687,6 +708,13 @@ * <code>System.mapLibraryName(libname)</code>. There may be a security * check, of <code>checkLink</code>. * + * <p>Note: Besides <code>java.library.path</code> a VM may chose to search + * for native libraries in a path that is specified by the + * <code>gnu.classpath.boot.library.path</code> system property. However + * this is for internal usage or development of GNU Classpath only. + * <b>A Java application must not load a non-system library by changing + * this property otherwise it will break compatibility.</b></p> + * * <p> * The library is loaded using the class loader associated with the * class associated with the invoking method. @@ -731,7 +759,7 @@ return; } throw new UnsatisfiedLinkError("Native library `" + libname - + "' not found (as file `" + filename + "')"); + + "' not found (as file `" + filename + "') in gnu.classpath.boot.library.path and java.library.path"); } /**
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches