[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cp-patches] FYI: Runtime - default property for system native libraries
From: |
Robert Schuster |
Subject: |
[cp-patches] FYI: Runtime - default property for system native libraries |
Date: |
Wed, 16 Mar 2005 01:14:27 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.5) Gecko/20050107 |
Clarified the documentation a bit and applied the newer one which you
can find attached.
Robert Schuster wrote:
See discussion mailing list for further info.
2005-03-16 Robert Schuster <address@hidden>
* 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 16 Mar 2005 00:08:58 -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,41 @@
{
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. On operating systems where a
LD_LIBRARY_PATH environment
+ // variable is available a VM should preset java.library.path with value
of this
+ // variable.
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 +710,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 +761,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");
}
/**