[kaffe] CVS kaffe (robilad): Fixed native library loading on Cygwin

Kaffe CVS cvs-commits at kaffe.org
Tue Sep 13 21:48:06 PDT 2005


PatchSet 6896 
Date: 2005/09/14 04:38:08
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Fixed native library loading on Cygwin

Members: 
	ChangeLog:1.4417->1.4418 
	libraries/javalib/java/lang/Runtime.java:1.36->1.37 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4417 kaffe/ChangeLog:1.4418
--- kaffe/ChangeLog:1.4417	Tue Sep 13 21:37:43 2005
+++ kaffe/ChangeLog	Wed Sep 14 04:38:08 2005
@@ -1,5 +1,15 @@
 2005-09-13  Dalibor Topic  <robilad at kaffe.org>
 
+	* libraries/java/java/lang/Runtime.java
+	(loadLibrary) Try multiple different 
+	prefixes and suffixes if library can't be loaded
+	using the mapped name. This takes care of 
+	Cygwin DLLs, Libtool modules and hopefully
+	will work for dylibs, jnilibs and similar
+	DSO variants as well.
+
+2005-09-13  Dalibor Topic  <robilad at kaffe.org>
+
 	* kaffe/scripts/javap.in,
 	kaffe/scripts/native2ascii.in,
 	kaffe/scripts/rmic.in,
Index: kaffe/libraries/javalib/java/lang/Runtime.java
diff -u kaffe/libraries/javalib/java/lang/Runtime.java:1.36 kaffe/libraries/javalib/java/lang/Runtime.java:1.37
--- kaffe/libraries/javalib/java/lang/Runtime.java:1.36	Sun Aug 21 00:41:02 2005
+++ kaffe/libraries/javalib/java/lang/Runtime.java	Wed Sep 14 04:37:46 2005
@@ -760,6 +760,26 @@
 	for (int i = 0; i < libpath.length; i++)
 	  if (loadLib(libpath[i] + filename, loader) != 0)
 	    return;
+
+	// OK. That did not work. Let's be creative and try different
+	// prefix-suffix combinations.
+	// NB: Yes, this is a wasteful implementation.
+
+	String [] prefixes = {"lib",
+			      "cyg", 
+			      "" };
+	String [] suffixes = {".so",
+			      ".dll", 
+			      ".la",
+			      ".a",
+			      ".dylib", 
+			      ".jnilib",
+			      ".dll.a"};
+	for (int j = 0; j < prefixes.length; j++)
+	    for (int k = 0; k < suffixes.length; k++)
+		for (int i = 0; i < libpath.length; i++)
+		    if (loadLib(libpath[i] + prefixes[j] + libname + suffixes[k], loader) != 0)
+			return;
       }
     throw new UnsatisfiedLinkError("Native library `" + libname
       + "' not found (as file `" + filename 




More information about the kaffe mailing list