[kaffe] Problem with JNI...
Jim Pick
jim at kaffe.org
Mon Jun 17 12:45:49 PDT 2002
Okay, I applied the patch to the head and the branch. I discovered that
the patch mishandled the error when it couldn't find the native library,
so I fixed that (I hope).
Cheers,
- Jim
On Tue, 2002-06-04 at 12:09, Timothy Stack wrote:
> > Hi!
>
> hi again,
>
> It looks like i forgot to add some code needed by some other changes, can
> you try the attached patch and see if it works. You'll need to run
> developers/autogen.sh because theres a configure.in change.
>
> > regards Martin
>
> sorry about the inconvenience,
>
> tim stack
> ----
>
> Index: acinclude.m4
> ===================================================================
> RCS file: /cvs/kaffe/kaffe/acinclude.m4,v
> retrieving revision 1.22
> diff -u -r1.22 acinclude.m4
> --- acinclude.m4 6 May 2002 02:59:55 -0000 1.22
> +++ acinclude.m4 4 Jun 2002 19:00:13 -0000
> @@ -3451,6 +3451,26 @@
> ])
>
>
> +# AC_LTDL_SHLIBEXT
> +# ----------------
> +AC_DEFUN(AC_LTDL_SHLIBEXT,
> +[AC_REQUIRE([_LT_AC_LTCONFIG_HACK])
> +AC_CACHE_CHECK([which extension is used for shared libraries],
> + libltdl_cv_shlibext,
> +[ac_last=
> + for ac_spec in $library_names_spec; do
> + ac_last="$ac_spec"
> + done
> + echo "$ac_last" | [sed 's/\[.*\]//;s/^[^.]*//;s/\$.*$//;s/\.$//'] > conftest
> +libltdl_cv_shlibext=`cat conftest`
> +rm -f conftest
> +])
> +if test -n "$libltdl_cv_shlibext"; then
> + AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext",
> + [Define to the extension used for shared libraries, say, ".so". ])
> +fi
> +])# AC_LTDL_SHLIBEXT
> +
> # AC_PROG_NM - find the path to a BSD-compatible name lister
> AC_DEFUN([AC_PROG_NM],
> [AC_REQUIRE([_LT_AC_LIBTOOL_SYS_PATH_SEPARATOR])dnl
> Index: configure.in
> ===================================================================
> RCS file: /cvs/kaffe/kaffe/configure.in,v
> retrieving revision 1.164
> diff -u -r1.164 configure.in
> --- configure.in 2 Jun 2002 16:02:57 -0000 1.164
> +++ configure.in 4 Jun 2002 19:00:24 -0000
> @@ -130,6 +130,7 @@
>
> AC_LIBTOOL_DLOPEN
> AC_LIBLTDL_CONVENIENCE
> +AC_REQUIRE([AC_LTDL_SHLIBEXT])
> AC_PROG_LIBTOOL
> AC_SUBST(LIBTOOL_DEPS)
> AC_SUBST(LIBLTDL)
> Index: external.c
> ===================================================================
> RCS file: /cvs/kaffe/kaffe/kaffe/kaffevm/external.c,v
> retrieving revision 1.39
> diff -u -r1.39 external.c
> --- external.c 3 Aug 2001 17:38:49 -0000 1.39
> +++ external.c 4 Jun 2002 19:00:41 -0000
> @@ -66,7 +66,7 @@
> #endif
>
> #ifndef LIBRARYLOAD
> -#define LIBRARYLOAD(desc,filename) ((desc)=lt_dlopenext((filename)))
> +#define LIBRARYLOAD(desc,filename) ((desc)=lt_dlopen((filename)))
> #endif
>
> #ifndef LIBRARYUNLOAD
> @@ -184,6 +184,24 @@
> return( retval );
> }
>
> +/* Standard libtool archive file extension. */
> +#undef LTDL_ARCHIVE_EXT
> +#define LTDL_ARCHIVE_EXT ".la"
> +
> +static char *libSuffixes[] = {
> + LTDL_ARCHIVE_EXT,
> +#ifdef LTDL_SHLIB_EXT
> + LTDL_SHLIB_EXT,
> +#endif
> + 0
> +};
> +
> +enum {
> + TRY_LOAD_FOUND,
> + TRY_LOAD_NOT_FOUND,
> + TRY_LOAD_ERROR,
> +};
> +
> /*
> * Link in a native library. If successful, returns an index >= 0 that
> * can be passed to unloadNativeLibrary(). Otherwise, returns -1 and
> @@ -193,7 +211,7 @@
> loadNativeLibrary2(char* path, int default_refs, char *errbuf, size_t errsiz)
> {
> struct _libHandle *lib;
> - int index;
> + int index, status;
>
> /* Find a library handle. If we find the library has already
> * been loaded, don't bother to get it again, just increase the
> @@ -236,25 +254,59 @@
> /* if we tested for existence here, libltdl wouldn't be able to look
> for system-dependent library names */
>
> + lib->name = KMALLOC(strlen(path)
> + + 16 /* XXX extension */
> + + 1);
> +
> blockAsyncSignals();
> - LIBRARYLOAD(lib->desc, path);
> + {
> + int lpc;
> +
> + status = TRY_LOAD_NOT_FOUND;
> + for( lpc = 0;
> + (status == TRY_LOAD_NOT_FOUND) && libSuffixes[lpc];
> + lpc++ )
> + {
> + sprintf(lib->name, "%s%s", path, libSuffixes[lpc]);
> + LIBRARYLOAD(lib->desc, lib->name);
> + if( lib->desc )
> + {
> + status = TRY_LOAD_FOUND;
> + }
> + else
> + {
> + const char *err = LIBRARYERROR();
> +
> + /* XXX Bleh, silly guessing system. */
> + if( err == 0 )
> + {
> + status = TRY_LOAD_ERROR;
> + strncpy(errbuf,
> + "Unknown error",
> + errsiz);
> + }
> + else if( (strstr(err, "ile not found") ||
> + strstr(err, "annot open")) )
> + {
> + status = TRY_LOAD_NOT_FOUND;
> + }
> + else
> + {
> + /* We'll assume its a real error. */
> + status = TRY_LOAD_ERROR;
> + strncpy(errbuf, err, errsiz);
> + }
> + }
> + }
> + }
> unblockAsyncSignals();
>
> if (lib->desc == 0) {
> - const char *err = LIBRARYERROR();
> -
> - if (err == 0) {
> - err = "Unknown error";
> - }
> - if (errbuf != 0) {
> - strncpy(errbuf, err, errsiz);
> - errbuf[errsiz - 1] = '\0';
> - }
> + errbuf[errsiz - 1] = '\0';
> return -1;
> }
>
> lib->ref = default_refs;
> - lib->name = KMALLOC(strlen(path) + 1);
> addToCounter(<mem, "vmmem-libltdl", 1, GCSIZEOF(lib->name));
> strcpy(lib->name, path);
>
More information about the kaffe
mailing list