This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: Use lib-gnu-pkg-quux.so, not gnu-pkg-quux.so
- To: java-patches at gcc dot gnu dot org
- Subject: Patch: Use lib-gnu-pkg-quux.so, not gnu-pkg-quux.so
- From: Anthony Green <green at redhat dot com>
- Date: Tue, 21 Aug 2001 13:00:54 -0700
- Reply-to: green at cygnus dot com
ClassLoader.findClass() looks in shared libraries like
"gnu-pkg-quux.so". This makes it difficult to use these same
libraries at link-time because "gcj -lgnu-pkg-quux" makes the linker
look for libgnu-pkg-quux.so, not gnu-pkg-quux.so.
This patch changes the runtime to look for lib-gnu-pkg-quux.so.
libgnu-pkg-quux.so was considered, but it seems too easy to conflict
with existing shared libaries (libgnu.so?). Users will have to link
with "gcj -l-gnu-pkg-quux". This seems easy to get used to, and has
the nice property that it makes it obvious that, for instance,
lib-gnu.so is probably a gcj library.
Ok?
AG
2001-08-21 Anthony Green <green@redhat.com>
* java/lang/natClassLoader.cc (findClass): Search for
lib-gnu-pkg-quux.so, not gnu-pkg-quux.so.
Index: libjava/java/lang/natClassLoader.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natClassLoader.cc,v
retrieving revision 1.32
diff -u -p -r1.32 natClassLoader.cc
--- natClassLoader.cc 2001/04/28 01:39:15 1.32
+++ natClassLoader.cc 2001/08/21 19:49:10
@@ -35,6 +35,7 @@ details. */
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/reflect/Modifier.h>
#include <java/lang/Runtime.h>
+#include <java/lang/StringBuffer.h>
#include <java/io/Serializable.h>
#include <java/lang/Cloneable.h>
@@ -184,11 +185,12 @@ gnu::gcj::runtime::VMClassLoader::findCl
if (! klass)
{
- // Turn `gnu.pkg.quux' into `gnu-pkg-quux'. Then search for a
- // module named (eg, on Linux) `gnu-pkg-quux.so', followed by
- // `gnu-pkg.so' and `gnu.so'. If loading one of these causes
- // the class to appear in the cache, then use it.
- jstring so_base_name = name->replace ('.', '-');
+ // Turn `gnu.pkg.quux' into `lib-gnu-pkg-quux'. Then search for
+ // a module named (eg, on Linux) `lib-gnu-pkg-quux.so', followed
+ // by `lib-gnu-pkg.so' and `lib-gnu.so'. If loading one of
+ // these causes the class to appear in the cache, then use it.
+ java::lang::StringBuffer *sb = new java::lang::StringBuffer (JvNewStringLatin1("lib-"));
+ jstring so_base_name = (sb->append (name)->toString ())->replace ('.', '-');
while (! klass && so_base_name && so_base_name->length() > 0)
{