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]

3.0.1 PATCH: Support JNI_OnLoad on systems without weak definitions


As mentioned in

	http://gcc.gnu.org/ml/java-patches/2001-q3/msg00128.html

Tru64 UNIX doesn't support ELF-style weak definitions.  The following patch
works around this by providing a dummy definition of JNI_OnLoad which is
necessary on such systems, and harmless on others, since the prior test for
JNI_OnLoad != NULL is replace by JNI_OnLoad != _JNI_OnLoad.

This patch allows me to successfully run most of the libjava testsuite on
alpha-dec-osf5.1:

		=== libjava Summary ===

# of expected passes		1465
# of unexpected failures	107
# of unexpected successes	10
# of expected failures		14
# of untested testcases		120

Most of the remaining failures are like this one:

FAIL: Array_1 execution from source compiled test
Yellow Zone stack overflow, thread 2

This is most likely due to the 8 kB default thread stack size on Tru64
UNIX.  I'll try to increase it via pthread_attr_setstacksize.  If this
works out, GCJ on Tru64 UNIX should be basically there :-)

This patch requires a few companion patches (not yet reviewed):

	http://gcc.gnu.org/ml/java-patches/2001-q3/msg00127.html
	http://gcc.gnu.org/ml/java-patches/2001-q3/msg00128.html
	http://gcc.gnu.org/ml/gcc-patches/2001-07/msg01381.html

I'll shortly submit the remaing piece thereof, fixing gcj --main
-save-temps which is broken by one of the patches above.

The current patch is independent of the rest, so ok for branch and mainline?

	Rainer

-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University

Email: ro@TechFak.Uni-Bielefeld.DE


Mon Jul 23 13:50:40 2001  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>

	* gnu/gcj/runtime/natFirstThread.cc (_JNI_OnLoad): New function.
	(JNI_OnLoad): Use it.
	(gnu::gcj::runtime::FirstThread::run): Check for _JNI_OnLoad, not
	NULL.

Index: libjava/gnu/gcj/runtime/natFirstThread.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/gnu/gcj/runtime/Attic/natFirstThread.cc,v
retrieving revision 1.4
diff -u -p -r1.4 natFirstThread.cc
--- natFirstThread.cc	2000/04/24 15:07:16	1.4
+++ natFirstThread.cc	2001/07/23 21:53:02
@@ -37,12 +37,19 @@ typedef void main_func (jobject);
 extern void (*_Jv_JVMPI_Notify_THREAD_START) (JVMPI_Event *event);
 #endif
 
-/* This will be non-NULL if the user has preloaded a JNI library, or
-   linked one into the executable.  */
+/* This will be different from _JNI_OnLoad if the user has preloaded a JNI
+   library, or linked one into the executable.  */
 extern "C" 
 {
-#pragma weak JNI_OnLoad
+  /* Some systems, like Tru64 UNIX, don't support weak definitions, so use
+     an empty dummy function to check if the user provided his own.  */
+#pragma weak JNI_OnLoad = _JNI_OnLoad
   extern jint JNI_OnLoad (JavaVM *, void *) __attribute__((weak));
+
+  jint _JNI_OnLoad (JavaVM *vm, void *)
+  {
+    return 0;
+  }
 }
 
 void
@@ -57,7 +64,7 @@ gnu::gcj::runtime::FirstThread::run (voi
      environment variable.  We take advatage of this here to allow for
      dynamically loading a JNI library into a fully linked executable.  */
 
-  if (JNI_OnLoad != NULL)
+  if (JNI_OnLoad != _JNI_OnLoad)
     {
       JavaVM *vm = _Jv_GetJavaVM ();
       if (vm == NULL)


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