This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch: Remove JNI_OnLoad
- To: Java Patch List <java-patches at gcc dot gnu dot org>
- Subject: Patch: Remove JNI_OnLoad
- From: Tom Tromey <tromey at redhat dot com>
- Date: 02 Aug 2001 19:53:33 -0600
- Reply-To: tromey at redhat dot com
I'm going to check this in on the trunk. This removes the JNI_OnLoad
lookup and call from the startup sequence.
I think this code isn't required. If JNI_OnLoad is defined in a
preload library, we will still need to dlopen it. That's because if
JNI_OnLoad is in use, then JNI will be in use. And the only reason to
do that is if you are writing a portable native library -- in which
case you already have to arrange for your Java code to load the native
library. So in the preload case we'll still be calling libltdl, etc.
The other case is if you want to use JNI_OnLoad in the executable
itself. But I don't think there is any particularly strong reason to
support that. I think it is reasonable if we support JNI for
compatibility. I don't think we need to provide JNI facilities above
what Sun provides.
FWIW the original JNI_OnLoad code was, I believe, based on my
misunderstanding of how dl preloading works.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* prims.cc (JNI_OnLoad): Don't declare.
(_JNI_OnLoad): Don't define.
(_Jv_CreateJavaVM): Don't handle JNI_OnLoad.
2001-08-02 Tom Tromey <tromey@redhat.com>
Index: prims.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/prims.cc,v
retrieving revision 1.55
diff -u -r1.55 prims.cc
--- prims.cc 2001/07/24 20:08:58 1.55
+++ prims.cc 2001/08/03 01:20:44
@@ -690,22 +690,7 @@
#endif
-/* This will be different from _JNI_OnLoad if the user has preloaded a JNI
- library, or linked one into the executable. */
-extern "C"
-{
- /* 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;
- }
-}
-
#ifndef DISABLE_GETENV_PROPERTIES
static char *
@@ -897,26 +882,6 @@
_Jv_JNI_Init ();
- /* Some systems let you preload shared libraries before running a
- program. Under Linux, this is done by setting the LD_PRELOAD
- environment variable. We take advatage of this here to allow for
- dynamically loading a JNI library into a fully linked executable. */
-
- if (JNI_OnLoad != _JNI_OnLoad)
- {
- JavaVM *vm = _Jv_GetJavaVM ();
- if (vm == NULL)
- {
- // FIXME: what?
- return -1;
- }
- jint vers = JNI_OnLoad (vm, NULL);
- if (vers != JNI_VERSION_1_1 && vers != JNI_VERSION_1_2)
- {
- // FIXME: unload the library.
- _Jv_Throw (new java::lang::UnsatisfiedLinkError (JvNewStringLatin1 ("unrecognized version from preloaded JNI_OnLoad")));
- }
- }
return 0;
}