natRuntime.cc (java::lang::Runtime::_load)): Take care of the fact that on Win32...
authorRanjit Mathew <rmathew@hotmail.com>
Mon, 3 Feb 2003 21:23:59 +0000 (21:23 +0000)
committerTom Tromey <tromey@gcc.gnu.org>
Mon, 3 Feb 2003 21:23:59 +0000 (21:23 +0000)
2003-02-03  Ranjit Mathew <rmathew@hotmail.com>

* java/lang/natRuntime.cc (java::lang::Runtime::_load)): Take care
of the fact that on Win32, JNI_OnLoad is an "stdcall" function and
could also have been exported as "JNI_OnLoad@8" (MinGW) or
"_JNI_OnLoad@8" (MSVC).

From-SVN: r62348

libjava/ChangeLog
libjava/java/lang/natRuntime.cc

index 11ba2edd366f84240574a6828528498dbdec1841..8a5597a98334add937b2398ec8a9cb24a4733e45 100644 (file)
@@ -1,3 +1,10 @@
+2003-02-03  Ranjit Mathew <rmathew@hotmail.com>
+
+       * java/lang/natRuntime.cc (java::lang::Runtime::_load)): Take care
+       of the fact that on Win32, JNI_OnLoad is an "stdcall" function and
+       could also have been exported as "JNI_OnLoad@8" (MinGW) or
+       "_JNI_OnLoad@8" (MSVC).
+
 2003-02-03  Ranjit Mathew <rmathew@hotmail.com>
 
        * resolve.cc (_Jv_JNIMethod::ncode): Use stdcall calling
index f74a1e76bcf0c71abe0e4290258f1bb75897f901..09f1e04f36191504309d185aab067f2fdab0f827 100644 (file)
@@ -1,6 +1,6 @@
 // natRuntime.cc - Implementation of native side of Runtime class.
 
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002  Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -241,6 +241,19 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
   add_library (h);
 
   void *onload = lt_dlsym (h, "JNI_OnLoad");
+
+#ifdef WIN32
+  // On Win32, JNI_OnLoad is an "stdcall" function taking two pointers
+  // (8 bytes) as arguments.  It could also have been exported as
+  // "JNI_OnLoad@8" (MinGW) or "_JNI_OnLoad@8" (MSVC).
+  if (onload == NULL)
+    {
+      onload = lt_dlsym (h, "JNI_OnLoad@8");
+      if (onload == NULL)
+       onload = lt_dlsym (h, "_JNI_OnLoad@8");
+    }
+#endif /* WIN32 */
+
   if (onload != NULL)
     {
       JavaVM *vm = _Jv_GetJavaVM ();
@@ -249,7 +262,7 @@ java::lang::Runtime::_load (jstring path, jboolean do_search)
          // FIXME: what?
          return;
        }
-      jint vers = ((jint (*) (JavaVM *, void *)) onload) (vm, NULL);
+      jint vers = ((jint (JNICALL *) (JavaVM *, void *)) onload) (vm, NULL);
       if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2
          && vers != JNI_VERSION_1_4)
        {