Commit 7af85558 by Tom Tromey Committed by Tom Tromey

Runtime.java (loadLibraryInternal): Declare.

	* java/lang/Runtime.java (loadLibraryInternal): Declare.
	* java/lang/natClassLoader.cc (_Jv_FindClass): Removed dead copy.
	(_Jv_FindClassInCache): Likewise.
	(_Jv_FindClass): Don't conditionalize body on INTERPRETER.
	(findSystemClass): Try to load class from compiled module.
	Include Runtime.h.
	* java/lang/natRuntime.cc (load): Use UTF-8 copy of filename.
	(loadLibrary): Likewise.
	(lt_preloaded_symbols): Define.
	(loadLibraryInternal): New method.
	* include/config.h.in: Rebuilt.
	* acconfig.h (USE_LTDL): Added.
	* Makefile.am (SUBDIRS): Added $(DIRLTDL).
	(INCLUDES): Added $(INCLTDL).b
	(libgcj_la_DEPENDENCIES): Added $(LIBLTDL).
	(libgcj_la_LIBADD): Likewise.
	* aclocal.m4, configure: Rebuilt.
	* configure.in: Added libltdl support.

From-SVN: r31472
parent 06f56737
2000-01-17 Tom Tromey <tromey@cygnus.com>
* java/lang/Runtime.java (loadLibraryInternal): Declare.
* java/lang/natClassLoader.cc (_Jv_FindClass): Removed dead copy.
(_Jv_FindClassInCache): Likewise.
(_Jv_FindClass): Don't conditionalize body on INTERPRETER.
(findSystemClass): Try to load class from compiled module.
Include Runtime.h.
* java/lang/natRuntime.cc (load): Use UTF-8 copy of filename.
(loadLibrary): Likewise.
(lt_preloaded_symbols): Define.
(loadLibraryInternal): New method.
* include/config.h.in: Rebuilt.
* acconfig.h (USE_LTDL): Added.
* Makefile.am (SUBDIRS): Added $(DIRLTDL).
(INCLUDES): Added $(INCLTDL).b
(libgcj_la_DEPENDENCIES): Added $(LIBLTDL).
(libgcj_la_LIBADD): Likewise.
* aclocal.m4, configure: Rebuilt.
* configure.in: Added libltdl support.
2000-01-15 Tom Tromey <tromey@cygnus.com>
* prims.cc (_Jv_PrimClass): Use `JV_STATE_NOTHING', not `0'.
......
......@@ -3,9 +3,9 @@
AUTOMAKE_OPTIONS = foreign no-installinfo
if TESTSUBDIR
SUBDIRS = testsuite gcj include
SUBDIRS = $(DIRLTDL) testsuite gcj include
else
SUBDIRS = gcj include
SUBDIRS = $(DIRLTDL) gcj include
endif
## ################################################################
......@@ -90,7 +90,7 @@ JC1FLAGS = -g -L$(here) @LIBGCJ_JAVAFLAGS@
LIBFFIINCS = -I$(top_srcdir)/../libffi/include -I../libffi/include
INCLUDES = -I$(top_srcdir) -Iinclude -I$(top_srcdir)/include \
$(GCINCS) $(THREADINCS) \
$(GCINCS) $(THREADINCS) $(INCLTDL) \
$(EH_COMMON_INCLUDE) $(ZINCS) $(LIBFFIINCS)
......@@ -116,9 +116,9 @@ libgcj_la_SOURCES = prims.cc jni.cc exception.cc \
EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \
$(c_source_files) $(java_source_files) $(built_java_source_files)
libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) $(nat_files) \
$(c_files) $(GCOBJS) $(THREADOBJS)
$(c_files) $(GCOBJS) $(THREADOBJS) $(LIBLTDL)
libgcj_la_LIBADD = $(javao_files) $(nat_files) $(c_files) $(GCOBJS) \
$(THREADOBJS) $(libffi_files)
$(THREADOBJS) $(libffi_files) $(LIBLTDL)
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) \
## The mysterious backslash is consumed by make.
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
......
......@@ -71,6 +71,7 @@ COMPPATH = @COMPPATH@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DIRLTDL = @DIRLTDL@
DIVIDESPEC = @DIVIDESPEC@
DLLTOOL = @DLLTOOL@
EXCEPTIONSPEC = @EXCEPTIONSPEC@
......@@ -81,15 +82,17 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
LD = @LD@
INCLTDL = @INCLTDL@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
LIBGCJ_JAVAFLAGS = @LIBGCJ_JAVAFLAGS@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
......@@ -99,7 +102,6 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
ZDEPS = @ZDEPS@
ZINCS = @ZINCS@
......@@ -110,9 +112,9 @@ libgcj_basedir = @libgcj_basedir@
AUTOMAKE_OPTIONS = foreign no-installinfo
@TESTSUBDIR_TRUE@SUBDIRS = \
@TESTSUBDIR_TRUE@testsuite gcj include
@TESTSUBDIR_TRUE@$(DIRLTDL) testsuite gcj include
@TESTSUBDIR_FALSE@SUBDIRS = \
@TESTSUBDIR_FALSE@gcj include
@TESTSUBDIR_FALSE@$(DIRLTDL) gcj include
@USE_LIBDIR_TRUE@toolexeclibdir = \
@USE_LIBDIR_TRUE@$(libdir)$(MULTISUBDIR)
@USE_LIBDIR_FALSE@toolexeclibdir = \
......@@ -171,7 +173,7 @@ JC1FLAGS = -g -L$(here) @LIBGCJ_JAVAFLAGS@
LIBFFIINCS = -I$(top_srcdir)/../libffi/include -I../libffi/include
INCLUDES = -I$(top_srcdir) -Iinclude -I$(top_srcdir)/include \
$(GCINCS) $(THREADINCS) \
$(GCINCS) $(THREADINCS) $(INCLTDL) \
$(EH_COMMON_INCLUDE) $(ZINCS) $(LIBFFIINCS)
......@@ -190,10 +192,10 @@ EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \
$(c_source_files) $(java_source_files) $(built_java_source_files)
libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) $(nat_files) \
$(c_files) $(GCOBJS) $(THREADOBJS)
$(c_files) $(GCOBJS) $(THREADOBJS) $(LIBLTDL)
libgcj_la_LIBADD = $(javao_files) $(nat_files) $(c_files) $(GCOBJS) \
$(THREADOBJS) $(libffi_files)
$(THREADOBJS) $(libffi_files) $(LIBLTDL)
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
......@@ -730,7 +732,7 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP_ENV = --best
DIST_SUBDIRS = testsuite gcj include gcj include
DIST_SUBDIRS = @DIRLTDL@ testsuite gcj include @DIRLTDL@ gcj include
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/$(srcdir)/$(CONVERT_DIR)/make-trie.P .deps/boehm.P \
.deps/defineclass.P .deps/exception.P .deps/gij.P \
......
......@@ -125,3 +125,6 @@
/* Define if getuid() and friends are missing. */
#undef NO_GETUID
/* Define if libltdl is in use. */
#undef USE_LTDL
......@@ -17,7 +17,20 @@ LIBGCJ_CONFIGURE(.)
AM_CONFIG_HEADER(include/config.h)
# Only use libltdl for native builds.
if test -z "${with_cross_host}"; then
AC_LIBLTDL_CONVENIENCE
AC_LIBTOOL_DLOPEN
DIRLTDL=libltdl
AC_DEFINE(USE_LTDL)
# Sigh. Libtool's macro doesn't do the right thing.
INCLTDL="-I\$(top_srcdir)/libltdl $INCLTDL"
fi
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
AC_SUBST(DIRLTDL)
AM_PROG_LIBTOOL
AC_CONFIG_SUBDIRS($DIRLDL)
if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
COMPPATH=.
......
......@@ -71,6 +71,7 @@ COMPPATH = @COMPPATH@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DIRLTDL = @DIRLTDL@
DIVIDESPEC = @DIVIDESPEC@
DLLTOOL = @DLLTOOL@
EH_COMMON_INCLUDE = @EH_COMMON_INCLUDE@
......@@ -82,16 +83,17 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
LD = @LD@
INCLTDL = @INCLTDL@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
LIBGCJ_JAVAFLAGS = @LIBGCJ_JAVAFLAGS@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
......@@ -101,7 +103,6 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
ZDEPS = @ZDEPS@
ZINCS = @ZINCS@
......
......@@ -71,6 +71,7 @@ COMPPATH = @COMPPATH@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DIRLTDL = @DIRLTDL@
DIVIDESPEC = @DIVIDESPEC@
DLLTOOL = @DLLTOOL@
EH_COMMON_INCLUDE = @EH_COMMON_INCLUDE@
......@@ -82,16 +83,17 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
LD = @LD@
INCLTDL = @INCLTDL@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
LIBGCJ_JAVAFLAGS = @LIBGCJ_JAVAFLAGS@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
......@@ -101,7 +103,6 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
ZDEPS = @ZDEPS@
ZINCS = @ZINCS@
......
......@@ -142,6 +142,9 @@
/* Define if getuid() and friends are missing. */
#undef NO_GETUID
/* Define if libltdl is in use. */
#undef USE_LTDL
/* Define if you have the access function. */
#undef HAVE_ACCESS
......
// Runtime.java - Runtime class.
/* Copyright (C) 1998, 1999 Cygnus Solutions
/* Copyright (C) 1998, 1999, 2000 Cygnus Solutions
This file is part of libgcj.
......@@ -97,6 +97,12 @@ public class Runtime
public native void load (String pathname);
public native void loadLibrary (String libname);
// This is a helper function for the ClassLoader which can load
// compiled libraries. Returns true if library (which is just the
// base name -- path searching is done by this function) was loaded,
// false otherwise.
native boolean loadLibraryInternal (String libname);
public native void runFinalization ();
// This method is static in JDK 1.1, but isn't listed as static in
......
......@@ -34,6 +34,7 @@ details. */
#include <java/lang/ClassCircularityError.h>
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/reflect/Modifier.h>
#include <java/lang/Runtime.h>
#define CloneableClass _CL_Q34java4lang9Cloneable
extern java::lang::Class CloneableClass;
......@@ -193,7 +194,35 @@ java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
jclass
gnu::gcj::runtime::VMClassLoader::findSystemClass (jstring name)
{
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), 0);
_Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name);
jclass klass = _Jv_FindClassInCache (name_u, 0);
if (! klass)
{
// Turn `gnu.pkg.quux' into `gnu-pkg-quux'. Then search for a
// module named (eg, on Linux) `gnu-pkg-quux.so', followed by
// `gnu-pkg.so' and `gnu.so'. If loading one of these causes
// the class to appear in the cache, then use it.
jstring so_base_name = name->replace ('.', '-');
while (! klass && so_base_name && so_base_name->length() > 0)
{
using namespace ::java::lang;
Runtime *rt = Runtime::getRuntime();
jboolean loaded = rt->loadLibraryInternal (so_base_name);
jint nd = so_base_name->lastIndexOf ('-');
if (nd == -1)
so_base_name = NULL;
else
so_base_name = so_base_name->substring (0, nd);
if (loaded)
klass = _Jv_FindClassInCache (name_u, 0);
}
}
return klass;
}
jclass
......@@ -403,31 +432,11 @@ _Jv_RegisterClass (jclass klass)
_Jv_RegisterClasses (classes);
}
#if 0
// NOTE: this one is out of date with the new loader stuff...
jclass
_Jv_FindClassInCache (jstring name, java::lang::ClassLoader *loader)
{
JvSynchronize sync (&ClassClass);
jint hash = name->hashCode();
jclass klass = loaded_classes[(_Jv_ushort) hash % HASH_LEN];
for ( ; klass; klass = klass->next)
{
if (loader == klass->loader
&& _Jv_equal (klass->name, name, hash))
break;
}
_Jv_MonitorExit (&ClassClass);
return klass;
}
#endif
jclass _Jv_FindClass (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader)
_Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
{
jclass klass = _Jv_FindClassInCache (name, loader);
#ifdef INTERPRETER
if (! klass)
{
jstring sname = _Jv_NewStringUTF (name->data);
......@@ -466,43 +475,9 @@ jclass _Jv_FindClass (_Jv_Utf8Const *name,
// we're loading, so that they can refer to themselves.
_Jv_WaitForState (klass, JV_STATE_LOADED);
}
#endif
return klass;
}
#if 0
// NOTE: this one is out of date with the new class loader stuff...
jclass
_Jv_FindClass (jstring name, java::lang::ClassLoader *loader)
{
jclass klass = _Jv_FindClassInCache (name, loader);
if (! klass)
{
if (loader)
{
klass = loader->loadClass(name);
}
else
{
// jmspec 5.3.1.2
// delegate to the system loader
klass = java::lang::ClassLoader::system.loadClass (sname);
// register that we're an initiating loader
if (klass)
_Jv_RegisterInitiatingLoader (klass, 0);
}
}
else
{
_Jv_WaitForState (klass, JV_STATE_LOADED);
}
return klass;
}
#endif
jclass
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
......
// natRuntime.cc - Implementation of native side of Runtime class.
/* Copyright (C) 1998, 1999 Cygnus Solutions
/* Copyright (C) 1998, 1999, 2000 Cygnus Solutions
This file is part of libgcj.
......@@ -20,6 +20,10 @@ details. */
#ifdef USE_LTDL
#include <ltdl.h>
/* FIXME: we don't always need this. The next libtool will let us use
AC_LTDL_PREOPEN to see if we do. */
const lt_dlsymlist lt_preloaded_symbols[1] = { { 0, 0 } };
#endif
void
......@@ -56,8 +60,12 @@ java::lang::Runtime::load (jstring path)
checkLink (path);
using namespace java::lang;
#ifdef USE_LTDL
jint len = _Jv_GetStringUTFLength (path);
char buf[len + 1];
jsize total = JvGetStringUTFRegion (path, 0, path->length(), buf);
buf[total] = '\0';
// FIXME: make sure path is absolute.
lt_dlhandle h = lt_dlopen (FIXME);
lt_dlhandle h = lt_dlopen (buf);
if (h == NULL)
{
const char *msg = lt_dlerror ();
......@@ -76,8 +84,12 @@ java::lang::Runtime::loadLibrary (jstring lib)
checkLink (lib);
using namespace java::lang;
#ifdef USE_LTDL
jint len = _Jv_GetStringUTFLength (lib);
char buf[len + 1];
jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf);
buf[total] = '\0';
// FIXME: make sure path is absolute.
lt_dlhandle h = lt_dlopenext (FIXME);
lt_dlhandle h = lt_dlopenext (buf);
if (h == NULL)
{
const char *msg = lt_dlerror ();
......@@ -89,6 +101,24 @@ java::lang::Runtime::loadLibrary (jstring lib)
#endif /* USE_LTDL */
}
jboolean
java::lang::Runtime::loadLibraryInternal (jstring lib)
{
JvSynchronize sync (this);
using namespace java::lang;
#ifdef USE_LTDL
jint len = _Jv_GetStringUTFLength (lib);
char buf[len + 1];
jsize total = JvGetStringUTFRegion (lib, 0, lib->length(), buf);
buf[total] = '\0';
// FIXME: make sure path is absolute.
lt_dlhandle h = lt_dlopenext (buf);
return h != NULL;
#else
return false;
#endif /* USE_LTDL */
}
void
java::lang::Runtime::init (void)
{
......
......@@ -71,6 +71,7 @@ COMPPATH = @COMPPATH@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DIRLTDL = @DIRLTDL@
DIVIDESPEC = @DIVIDESPEC@
DLLTOOL = @DLLTOOL@
EH_COMMON_INCLUDE = @EH_COMMON_INCLUDE@
......@@ -82,16 +83,17 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
LD = @LD@
INCLTDL = @INCLTDL@
LIBDATASTARTSPEC = @LIBDATASTARTSPEC@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
LIBGCJ_JAVAFLAGS = @LIBGCJ_JAVAFLAGS@
LIBLTDL = @LIBLTDL@
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
PERL = @PERL@
RANLIB = @RANLIB@
......@@ -101,7 +103,6 @@ THREADINCS = @THREADINCS@
THREADLIBS = @THREADLIBS@
THREADOBJS = @THREADOBJS@
THREADSPEC = @THREADSPEC@
USE_SYMBOL_UNDERSCORE = @USE_SYMBOL_UNDERSCORE@
VERSION = @VERSION@
ZDEPS = @ZDEPS@
ZINCS = @ZINCS@
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment