diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rwxr-xr-x | tools/Makefile.am | 18 | ||||
-rw-r--r-- | tools/toolwrapper.c | 40 |
4 files changed, 56 insertions, 19 deletions
@@ -1,3 +1,14 @@ +2006-08-18 Thomas Fitzsimmons <fitzsim@redhat.com> + + * configure.ac (tool-wrappers): Check for ltdl support when tool + wrapper binaries are enabled. + * tools/Makefile.am (LIBJVM): Remove variable. + (AM_CPPFLAGS): Add LIBJVM define. + (gappletviewer_LDFLAGS, gjarsigner_LDFLAGS, gkeytool_LDFLAGS, + gjar_LDFLAGS, gnative2ascii_LDFLAGS, gserialver_LDFLAGS, + gjavah_LDFLAGS): Remove variables. + * tools/toolwrapper.c (main): Use dlopen to load libjvm library. + 2006-08-18 Tom Tromey <tromey@redhat.com> * gnu/java/util/prefs/NodeWriter.java (writeParents): Removed diff --git a/configure.ac b/configure.ac index 1c7f7c768..5089e0199 100644 --- a/configure.ac +++ b/configure.ac @@ -287,7 +287,11 @@ dnl ----------------------------------------------------------- AC_ARG_ENABLE([tool-wrappers], [AS_HELP_STRING(--enable-tool-wrappers,create tool wrapper binaries [default=no])], [case x"${enableval}" in - xyes) COMPILE_WRAPPERS=yes ;; + xyes) + COMPILE_WRAPPERS=yes; + AC_CHECK_HEADERS([ltdl.h],, [AC_MSG_ERROR(cannot find ltdl.h)]) + AC_CHECK_LIB(ltdl, lt_dlopen,, [AC_MSG_ERROR(cannot find libltdl)]) + ;; xno) COMPILE_WRAPPERS=no ;; x) COMPILE_WRAPPERS=yes ;; *) COMPILE_WRAPPERS=yes ;; diff --git a/tools/Makefile.am b/tools/Makefile.am index 2f417e69a..5d5d9a499 100755 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -30,62 +30,46 @@ bin_SCRIPTS = bin_PROGRAMS = gappletviewer gjarsigner gkeytool \ gjar gnative2ascii gserialver $(javah) -if FOUND_GCJ -LIBJVM = -lgcj -else -if FOUND_CACAO -LIBJVM = -ljvm -else -LIBJVM = -endif -endif - AM_CPPFLAGS = -Wall \ -I$(top_srcdir)/include \ + -DLIBJVM="\"$(libdir)/libjvm\"" \ -DTOOLS_ZIP="\"$(TOOLSdir)/$(TOOLS_ZIP)\"" gappletviewer_SOURCES = toolwrapper.c gappletviewer_CFLAGS = \ -DTOOLPACKAGE="\"appletviewer\"" \ -DTOOLNAME="\"gappletviewer\"" -gappletviewer_LDFLAGS = -L$(libdir) $(LIBJVM) gjarsigner_SOURCES = toolwrapper.c gjarsigner_CFLAGS = \ -DTOOLPACKAGE="\"jarsigner\"" \ -DTOOLNAME="\"gjarsigner\"" -gjarsigner_LDFLAGS = -L$(libdir) $(LIBJVM) gkeytool_SOURCES = toolwrapper.c gkeytool_CFLAGS = \ -DTOOLPACKAGE="\"keytool\"" \ -DTOOLNAME="\"gkeytool\"" -gkeytool_LDFLAGS = -L$(libdir) $(LIBJVM) gjar_SOURCES = toolwrapper.c gjar_CFLAGS = \ -DTOOLPACKAGE="\"jar\"" \ -DTOOLNAME="\"gjar\"" -gjar_LDFLAGS = -L$(libdir) $(LIBJVM) gnative2ascii_SOURCES = toolwrapper.c gnative2ascii_CFLAGS = \ -DTOOLPACKAGE="\"native2ascii\"" \ -DTOOLNAME="\"gnative2ascii\"" -gnative2ascii_LDFLAGS = -L$(libdir) $(LIBJVM) gserialver_SOURCES = toolwrapper.c gserialver_CFLAGS = \ -DTOOLPACKAGE="\"serialver\"" \ -DTOOLNAME="\"gserialver\"" -gserialver_LDFLAGS = -L$(libdir) $(LIBJVM) if USE_ASM gjavah_SOURCES = toolwrapper.c gjavah_CFLAGS = \ -DTOOLPACKAGE="\"javah\"" \ -DTOOLNAME="\"gjavah\"" -gjavah_LDFLAGS = -L$(libdir) $(LIBJVM) endif else diff --git a/tools/toolwrapper.c b/tools/toolwrapper.c index 9ad14ac6d..9f4720ab9 100644 --- a/tools/toolwrapper.c +++ b/tools/toolwrapper.c @@ -37,6 +37,7 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ #include <jni.h> +#include <ltdl.h> #include <string.h> #include <stdlib.h> #include "config.h" @@ -51,6 +52,9 @@ union env_union JNIEnv *jni_env; }; +/* Typedef for JNI_CreateJavaVM dlopen call. */ +typedef jint createVM (JavaVM **, void **, void *); + int main (int argc, const char** argv) { @@ -68,6 +72,10 @@ main (int argc, const char** argv) int non_vm_argc; int i; int classpath_found = 0; + /* Variables for JNI_CreateJavaVM dlopen call. */ + lt_dlhandle libjvm_handle = NULL; + createVM* libjvm_create = NULL; + int libjvm_error = 0; env = NULL; jvm = NULL; @@ -152,7 +160,27 @@ main (int argc, const char** argv) vm_args.version = JNI_VERSION_1_2; vm_args.ignoreUnrecognized = JNI_TRUE; - result = JNI_CreateJavaVM (&jvm, &tmp.void_env, &vm_args); + /* dlopen libjvm.so */ + libjvm_error = lt_dlinit (); + if (libjvm_error) + { + fprintf (stderr, TOOLNAME ": lt_dlinit failed.\n"); + goto destroy; + } + + libjvm_handle = lt_dlopenext (LIBJVM); + if (!libjvm_handle) + { + fprintf (stderr, TOOLNAME ": failed to open " LIBJVM "\n"); + goto destroy; + } + libjvm_create = (createVM*) lt_dlsym (libjvm_handle, "JNI_CreateJavaVM"); + if (!libjvm_create) + { + fprintf (stderr, TOOLNAME ": failed to load JNI_CreateJavaVM symbol from " LIBJVM "\n"); + goto destroy; + } + result = (*libjvm_create) (&jvm, &tmp.void_env, &vm_args); if (result < 0) { @@ -216,5 +244,15 @@ main (int argc, const char** argv) (*jvm)->DestroyJavaVM (jvm); } + /* libltdl cleanup */ + if (libjvm_handle) + { + if (lt_dlclose (libjvm_handle) != 0) + fprintf (stderr, TOOLNAME ": failed to close " LIBJVM "\n"); + } + + if (lt_dlexit () != 0) + fprintf (stderr, TOOLNAME ": lt_dlexit failed.\n"); + return 1; } |