diff options
author | Tom Tromey <tromey@cygnus.com> | 2000-02-08 00:26:58 +0000 |
---|---|---|
committer | Tom Tromey <tromey@gcc.gnu.org> | 2000-02-08 00:26:58 +0000 |
commit | 3fd64b5a09de7b7128482bb764c9250b474ac78f (patch) | |
tree | 8f96de6d10a1be2f4df62afb63420832f7de519b /libjava/java/lang/natRuntime.cc | |
parent | 278abd2849d9546d8591ba88541a50b11d8337ec (diff) | |
download | gcc-3fd64b5a09de7b7128482bb764c9250b474ac78f.zip gcc-3fd64b5a09de7b7128482bb764c9250b474ac78f.tar.gz gcc-3fd64b5a09de7b7128482bb764c9250b474ac78f.tar.bz2 |
Runtime.java (_load): Declare.
* java/lang/Runtime.java (_load): Declare.
(load, loadLibrary): Wrote in terms of _load.
* java/lang/natRuntime.cc (load): Call JNI_OnLoad if it appears in
library.
(loadLibrary): Likewise.
Include <jni.h>.
(_load): New method.
(loadLibrary, load): Removed.
From-SVN: r31846
Diffstat (limited to 'libjava/java/lang/natRuntime.cc')
-rw-r--r-- | libjava/java/lang/natRuntime.cc | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc index dd8b0d0..d391ff4 100644 --- a/libjava/java/lang/natRuntime.cc +++ b/libjava/java/lang/natRuntime.cc @@ -18,6 +18,8 @@ details. */ #include <java/lang/UnknownError.h> #include <java/lang/UnsatisfiedLinkError.h> +#include <jni.h> + #ifdef USE_LTDL #include <ltdl.h> @@ -99,7 +101,7 @@ java::lang::Runtime::gc (void) } void -java::lang::Runtime::load (jstring path) +java::lang::Runtime::_load (jstring path, jboolean do_search) { JvSynchronize sync (this); checkLink (path); @@ -110,39 +112,29 @@ java::lang::Runtime::load (jstring path) jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf); buf[total] = '\0'; // FIXME: make sure path is absolute. - lt_dlhandle h = lt_dlopen (buf); + lt_dlhandle h = do_search ? lt_dlopenext (buf) : lt_dlopen (buf); if (h == NULL) { const char *msg = lt_dlerror (); _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 (msg))); } -#else - _Jv_Throw (new UnknownError - (JvNewStringLatin1 ("Runtime.load not implemented"))); -#endif /* USE_LTDL */ -} -void -java::lang::Runtime::loadLibrary (jstring lib) -{ - JvSynchronize sync (this); - checkLink (lib); - using namespace java::lang; -#ifdef USE_LTDL - jint len = _Jv_GetStringUTFLength (lib); - char buf[len + 1]; - jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf); - buf[total] = '\0'; - // FIXME: make sure path is absolute. - lt_dlhandle h = lt_dlopenext (buf); - if (h == NULL) + void *onload = lt_dlsym (h, "JNI_OnLoad"); + if (onload != NULL) { - const char *msg = lt_dlerror (); - _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 (msg))); + // FIXME: need invocation API to get JavaVM. + jint vers = ((jint (*) (...)) onload) (NULL, NULL); + if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2) + { + // FIXME: unload the library. + _Jv_Throw (new UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from JNI_OnLoad"))); + } } #else _Jv_Throw (new UnknownError - (JvNewStringLatin1 ("Runtime.loadLibrary not implemented"))); + (JvNewStringLatin1 (do_search + ? "Runtime.loadLibrary not implemented" + : "Runtime.load not implemented"))); #endif /* USE_LTDL */ } |