This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

JNI/Win32 Patch #2: Fix lookup of "JNI_OnLoad" on loading a JNI DLL


Hi,

    This patch proposes to fix the lookup for "JNI_OnLoad"
when loading a JNI DLL on Win32, to take care of the differences
between BCC, MinGW and MSVC in exporting an "stdcall" function.

ChangeLog:

2002-12-07  Ranjit Mathew  <rmathew@hotmail.com>

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

------------------------------ 8< ------------------------------
--- natRuntime.cc	2002-11-13 00:07:28.000000000 +0530
+++ natRuntime.cc	2002-12-07 06:55:17.000000000 +0530
@@ -194,4 +194,21 @@

   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)
     {
------------------------------ 8< ------------------------------

Sincerely Yours,
Ranjit.

--
Ranjit Mathew        Email: rmathew AT hotmail DOT com
Bangalore,
INDIA.               Web: http://ranjitmathew.tripod.com/




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]