[multiple changes]

1999-08-09  Anthony Green  <green@cygnus.com>

        * gij.cc: New file.

        * include/config.h.in: Rebuilt.
        * acconfig.h: Add INTERPRETER.

        * configure: Rebuilt.

        * Makefile.in: Rebuilt.
        * Makefile.am (libffi_files): Identify the libffi object files for
        inclusion in libgcj.
        (LIBFFIINCS): Define.

        * interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1):
        Dummy definition for configurations without an interpreter.

        * java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to
        java::lang::Boolean constructor.

        * include/java-interp.h: Always include java-cpool.h.

        * java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0
        when INTERPRETER not defined.

        * java/lang/Class.h (finalize): Define.

        * gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch
        IOException from File.getCanonicalPath.
        (getStream): Likewise.

        * NEWS: More news.
        * THANKS: More thanks.

1999-08-09  Kresten Krab Thorup  <krab@gnu.org>

        * resolve.cc (get_ffi_type_from_signature): Generate uint16 for
        jchar type.
        (_Jv_PrepareClass): Allow non-abstract classes to
        have abstract subclasses.
        (_Jv_ResolvePoolEntry): Revert subclass check for protected
        fields and methods.
        * interpret.cc (continue1/perform_invoke): Don't sign extend
        uint16 return val.
        (continue1/lshl,lshr): Push long, not int.
        (continue1/ulshr): Use UINT64, not long long.
        * defineclass.cc (handleFieldsEnd): Handle case when all fields
        are static.
        * java/lang/natClass.cc (forName): Add call to _Jv_InitClass.
        * java/lang/FirstThread.java (run): Add top-level exception
        handler.
        (run0): Renamed from run.

1999-08-08  Kresten Krab Thorup  <krab@gnu.org>

        * configure.in (--with-interpreter): Added.
        * include/config.h.in (INTERPRETER): Added.

        * java/lang/ClassLoader.java: File replaced.
        * java/lang/VMClassLoader.java: New file.
        * java/lang/natClassLoader.cc: New file.
        * gnu/gcj/runtime/MethodInvocation.java: New file.
        * gnu/gcj/util/path/SearchPath.java: New file.
        * gnu/gcj/util/path/PathEntry.java: New file.
        * gnu/gcj/util/path/DirectoryPathEntry.java: New file.
        * gnu/gcj/util/path/ZipPathEntry.java: New file.
        * gnu/gcj/util/path/URLPathEntry.java: New file.
        * gnu/gcj/util/path/CacheEntry.java: New file.
        * include/java-interp.h: New file.
        * include/java-cpool.h: New file.
        * include/java-insns.h: New file.
        * defineclass.cc: New file.
        * interpret.cc: New file.
        * resolve.cc: New file.

        * java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass,
        _Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass,
        _Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc.
        (finalize): New.
        (STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE,
        STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_
        prefix.
        (initializeClass): Use new JV_ prefixed names.  Also, call
        ClassLoader::resolveClass instead of _Jv_ResolveClass.

        * java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING,
        JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED,
        JV_STATE_LINKED): New.
        (_Jv_WaitForState, _Jv_RegisterInitiatingLoader,
        _Jv_UnregisterClass, _Jv_InternClassStrings): New friends.
        (_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod,
        _Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass,
        _Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod,
        _Jv_InterpMethodInvocation): New friends for interpreter.
        (finalize): New.
        (CONSTANT_Class, CONSTANT_String, etc.): Moved to
        include/java-cpool.h and renamed with JV_ prefix.

        * include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New
        decls.
        (_Jv_UnregisterClass): New decl.

        * java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added
        class loader argument.
        (_Jv_FindClass): Use class loader.

        * prims.cc (_Jv_makeUtf8Const): New function.
        (_Jv_NewObjectArray): Change use of _Jv_FindArrayClass.
        (_Jv_NewPrimArray): Ditto.
        (_Jv_FindClassFromSignature): Ditto.
        * java/lang/reflect/natArray.cc (newInstance): Ditto.
        * java/lang/reflect/natMethod.cc (getType): Ditto.

        * include/java-field.h (_Jv_Field::isRef): Make robust for
        non-resolved contexts.

        * boehm.cc (_Jv_MarkObj): Mark interpreter-related fields.
        Also, don't mark class->next field.

        * java/lang/VirtualMachineError.java: Added FIXME note.

        * configure.in (INTERPSPEC): New spec.
        * libgcj.spec.in: Added INTERPSPEC.
        * Makefile.am: Added gcjh friends for java/lang/VMClassLoader and
        gnu/gcj/runtime/MethodInvocation.
        (libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc.
        (ordinary_java_source_files): Added above mentioned java classes.

        * configure: Rebuilt.
        * Makefile.in: Rebuilt.

From-SVN: r28597
This commit is contained in:
Anthony Green 1999-08-08 14:06:23 +00:00
parent 63e5e3e0db
commit 58eb6e7cef
42 changed files with 8341 additions and 598 deletions

View file

@ -1,3 +1,132 @@
1999-08-09 Anthony Green <green@cygnus.com>
* gij.cc: New file.
* include/config.h.in: Rebuilt.
* acconfig.h: Add INTERPRETER.
* Makefile.in: Rebuilt.
* Makefile.am (libffi_files): Identify the libffi object files for
inclusion in libgcj.
(LIBFFIINCS): Define.
* interpret.cc (gnu::gcj::runtime::MethodInvocation::continue1):
Dummy definition for configurations without an interpreter.
* java/net/natPlainSocketImpl.cc (getOption): Disamiguate call to
java::lang::Boolean constructor.
* include/java-interp.h: Always include java-cpool.h.
* java/lang/natClassLoader.cc (getVMClassLoader0): Always return 0
when INTERPRETER not defined.
* java/lang/Class.h (finalize): Define.
* gnu/gcj/util/path/DirectoryPathEntry.java (getURL): Catch
IOException from File.getCanonicalPath.
(getStream): Likewise.
* NEWS: More news.
* THANKS: More thanks.
1999-08-09 Kresten Krab Thorup <krab@gnu.org>
* resolve.cc (get_ffi_type_from_signature): Generate uint16 for
jchar type.
(_Jv_PrepareClass): Allow non-abstract classes to
have abstract subclasses.
(_Jv_ResolvePoolEntry): Revert subclass check for protected
fields and methods.
* interpret.cc (continue1/perform_invoke): Don't sign extend
uint16 return val.
(continue1/lshl,lshr): Push long, not int.
(continue1/ulshr): Use UINT64, not long long.
* defineclass.cc (handleFieldsEnd): Handle case when all fields
are static.
* java/lang/natClass.cc (forName): Add call to _Jv_InitClass.
* java/lang/FirstThread.java (run): Add top-level exception
handler.
(run0): Renamed from run.
1999-08-08 Kresten Krab Thorup <krab@gnu.org>
* configure.in (--with-interpreter): Added.
* include/config.h.in (INTERPRETER): Added.
* java/lang/ClassLoader.java: File replaced.
* java/lang/VMClassLoader.java: New file.
* java/lang/natClassLoader.cc: New file.
* gnu/gcj/runtime/MethodInvocation.java: New file.
* gnu/gcj/util/path/SearchPath.java: New file.
* gnu/gcj/util/path/PathEntry.java: New file.
* gnu/gcj/util/path/DirectoryPathEntry.java: New file.
* gnu/gcj/util/path/ZipPathEntry.java: New file.
* gnu/gcj/util/path/URLPathEntry.java: New file.
* gnu/gcj/util/path/CacheEntry.java: New file.
* include/java-interp.h: New file.
* include/java-cpool.h: New file.
* include/java-insns.h: New file.
* defineclass.cc: New file.
* interpret.cc: New file.
* resolve.cc: New file.
* java/lang/natClass.cc (loaded_classes, _Jv_RegisterClass,
_Jv_RegisterClasses, _Jv_FindClassInCache, _Jv_FindClass,
_Jv_NewClass, _Jv_FindArrayClass): Moved to natClassLoader.cc.
(finalize): New.
(STATE_NOTHING, STATE_RESOLVED, STATE_IN_PROGRESS, STATE_DONE,
STATE_ERROR): Moved to java/lang/Class.h and renamed with JV_
prefix.
(initializeClass): Use new JV_ prefixed names. Also, call
ClassLoader::resolveClass instead of _Jv_ResolveClass.
* java/lang/Class.h (JV_STATE_PRELOADING, JV_STATE_LOADING,
JV_STATE_LOADED, JV_STATE_COMPILED, JV_STATE_PREPARED,
JV_STATE_LINKED): New.
(_Jv_WaitForState, _Jv_RegisterInitiatingLoader,
_Jv_UnregisterClass, _Jv_InternClassStrings): New friends.
(_Jv_IsInterpretedClass, _Jv_InitField, _Jv_LookupDeclaredMethod,
_Jv_DetermineVTableIndex, _Jv_ResolvePoolEntry, _Jv_PrepareClass,
_Jv_ClassReader, _Jv_InterpClass, _Jv_InterpMethod,
_Jv_InterpMethodInvocation): New friends for interpreter.
(finalize): New.
(CONSTANT_Class, CONSTANT_String, etc.): Moved to
include/java-cpool.h and renamed with JV_ prefix.
* include/jvm.h (_Jv_makeUtf8Const, _Jv_makeUtf8TypeConst): New
decls.
(_Jv_UnregisterClass): New decl.
* java/lang/natClassLoader.cc (_Jv_FindArrayClass): Added
class loader argument.
(_Jv_FindClass): Use class loader.
* prims.cc (_Jv_makeUtf8Const): New function.
(_Jv_NewObjectArray): Change use of _Jv_FindArrayClass.
(_Jv_NewPrimArray): Ditto.
(_Jv_FindClassFromSignature): Ditto.
* java/lang/reflect/natArray.cc (newInstance): Ditto.
* java/lang/reflect/natMethod.cc (getType): Ditto.
* include/java-field.h (_Jv_Field::isRef): Make robust for
non-resolved contexts.
* boehm.cc (_Jv_MarkObj): Mark interpreter-related fields.
Also, don't mark class->next field.
* java/lang/VirtualMachineError.java: Added FIXME note.
* configure.in (INTERPSPEC): New spec.
* libgcj.spec.in: Added INTERPSPEC.
* Makefile.am: Added gcjh friends for java/lang/VMClassLoader and
gnu/gcj/runtime/MethodInvocation.
(libgcj_la_SOURCES): Added resolve.cc defineclass.cc interpret.cc.
(ordinary_java_source_files): Added above mentioned java classes.
* configure: Rebuilt.
* Makefile.in: Rebuilt.
1999-08-06 Tom Tromey <tromey@cygnus.com>
* configure: Rebuilt.

View file

@ -27,7 +27,7 @@ data_DATA = libgcj.zip
## For now, only on native systems.
if NATIVE
bin_PROGRAMS = jv-convert
bin_PROGRAMS = jv-convert gij
endif
## ################################################################
@ -77,8 +77,10 @@ endif
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
LIBFFIINCS = -I$(top_srcdir)/../libffi/include -I../libffi/include
INCLUDES = -Iinclude -I$(top_srcdir)/include $(GCINCS) $(THREADINCS) \
$(EH_COMMON_INCLUDE) $(ZINCS)
$(EH_COMMON_INCLUDE) $(ZINCS) $(LIBFFIINCS)
DIVIDESPEC = @DIVIDESPEC@
@ -97,13 +99,17 @@ c_files = $(c_source_files:.c=.lo)
javao_files = $(java_source_files:.java=.lo) \
$(built_java_source_files:.java=.lo)
libgcj_la_SOURCES = prims.cc jni.cc exception.cc
## Extract the libffi object file names.
libffi_files = `$(AR) t ../libffi/.libs/libffi.a 2>/dev/null | sed 's/\.o/\.lo/g' | sed 's/^/..\/libffi\//g'`
libgcj_la_SOURCES = prims.cc jni.cc exception.cc \
resolve.cc defineclass.cc interpret.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)
libgcj_la_LIBADD = $(javao_files) $(nat_files) $(c_files) $(GCOBJS) \
$(THREADOBJS)
$(THREADOBJS) $(libffi_files)
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) \
## The mysterious backslash is consumed by make.
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
@ -230,6 +236,16 @@ java/lang/reflect/Method.h: java/lang/reflect/Method.class libgcj.zip
-friend 'java::lang::Class;' \
$(basename $<)
java/lang/VMClassLoader.h: java/lang/VMClassLoader.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'java::lang::ClassLoader;' \
$(basename $<)
gnu/gcj/runtime/MethodInvocation.h: gnu/gcj/runtime/MethodInvocation.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'class _Jv_InterpMethod;' \
$(basename $<)
## ################################################################
@ -299,6 +315,26 @@ jv_convert_LDADD = $(convert_source_files:.java=.lo) libgcj.la \
jv_convert_DEPENDENCIES = $(convert_source_files:.java=.lo) \
$(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec
gij_SOURCES =
EXTRA_gij_SOURCES = gij.cc
## We need -nodefaultlibs because we want to avoid gcj's `-lgcj'. We
## need this because we are explicitly using libtool to link using the
## `.la' file.
gij_LDFLAGS = -rpath $(toolexeclibdir)
gij_LINK = $(LIBTOOL) --mode=link $(GCJ) $(JC1FLAGS) $(LDFLAGS) \
-o gij
## We explicitly link in the libraries we need. This way we don't
## need -nodefaultlibs, so we can still rely on gcj picking up the
## system libraries we need (via the specs file).
## We need the -L so that gcj can find libgcj with `-lgcj'.
## FIXME: should be _libs on some systems.
gij_LDADD = gij.lo libgcj.la \
$(GCLIBS) $(THREADLIBS) $(ZLIBS) -L$(here)/.libs
## Depend on the spec file to make sure it is up to date before
## linking this program.
gij_DEPENDENCIES = gij.lo \
$(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec
# The Unicode consortium does not permit re-distributing the file JIS0201.TXT.
# You can get it from ftp://ftp.unicode.org/Public/MAPPINGS/EASTASIA/JIS/.
@ -444,6 +480,13 @@ built_java_source_files = java/lang/ConcreteProcess.java
## convert_source_files. If the .java file has a hand-maintained
## header, please list it in special_java_source_files.
ordinary_java_source_files = $(convert_source_files) \
gnu/gcj/runtime/MethodInvocation.java \
gnu/gcj/util/path/SearchPath.java \
gnu/gcj/util/path/PathEntry.java \
gnu/gcj/util/path/DirectoryPathEntry.java \
gnu/gcj/util/path/ZipPathEntry.java \
gnu/gcj/util/path/URLPathEntry.java \
gnu/gcj/util/path/CacheEntry.java \
gnu/gcj/text/BaseBreakIterator.java \
gnu/gcj/text/CharacterBreakIterator.java \
gnu/gcj/text/LineBreakIterator.java \
@ -522,6 +565,7 @@ java/lang/ClassCastException.java \
java/lang/ClassCircularityError.java \
java/lang/ClassFormatError.java \
java/lang/ClassLoader.java \
java/lang/VMClassLoader.java \
java/lang/ClassNotFoundException.java \
java/lang/CloneNotSupportedException.java \
java/lang/Cloneable.java \
@ -719,6 +763,7 @@ java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/lang/natCharacter.cc \
java/lang/natClass.cc \
java/lang/natClassLoader.cc \
java/lang/natConcreteProcess.cc \
java/lang/natDouble.cc \
java/lang/natFirstThread.cc \

View file

@ -78,6 +78,7 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
INTERPSPEC = @INTERPSPEC@
LD = @LD@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@
@ -120,7 +121,7 @@ toolexeclib_DATA = libgcj.spec
data_DATA = libgcj.zip
@NATIVE_TRUE@bin_PROGRAMS = \
@NATIVE_TRUE@jv-convert
@NATIVE_TRUE@jv-convert gij
@CANADIAN_TRUE@@NULL_TARGET_TRUE@GCJ = \
@CANADIAN_TRUE@@NULL_TARGET_TRUE@gcj
@CANADIAN_TRUE@@NULL_TARGET_FALSE@GCJ = \
@ -156,8 +157,10 @@ AM_CXXFLAGS = -fno-rtti -fvtable-thunks @LIBGCJ_CXXFLAGS@ $(WARNINGS)
JCFLAGS = -g
JC1FLAGS = -g @LIBGCJ_JAVAFLAGS@
LIBFFIINCS = -I$(top_srcdir)/../libffi/include -I../libffi/include
INCLUDES = -Iinclude -I$(top_srcdir)/include $(GCINCS) $(THREADINCS) \
$(EH_COMMON_INCLUDE) $(ZINCS)
$(EH_COMMON_INCLUDE) $(ZINCS) $(LIBFFIINCS)
DIVIDESPEC = @DIVIDESPEC@
@ -168,7 +171,11 @@ javao_files = $(java_source_files:.java=.lo) \
$(built_java_source_files:.java=.lo)
libgcj_la_SOURCES = prims.cc jni.cc exception.cc
libffi_files = `$(AR) t ../libffi/.libs/libffi.a 2>/dev/null | sed 's/\.o/\.lo/g' | sed 's/^/..\/libffi\//g'`
libgcj_la_SOURCES = prims.cc jni.cc exception.cc \
resolve.cc defineclass.cc interpret.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)
@ -176,7 +183,7 @@ libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) $(nat_files) \
$(c_files) $(GCOBJS) $(THREADOBJS)
libgcj_la_LIBADD = $(javao_files) $(nat_files) $(c_files) $(GCOBJS) \
$(THREADOBJS)
$(THREADOBJS) $(libffi_files)
libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) \
-version-info `grep -v '^\#' $(srcdir)/libtool-version`
@ -217,6 +224,19 @@ jv_convert_DEPENDENCIES = $(convert_source_files:.java=.lo) \
$(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec
gij_SOURCES =
EXTRA_gij_SOURCES = gij.cc
gij_LDFLAGS = -rpath $(toolexeclibdir)
gij_LINK = $(LIBTOOL) --mode=link $(GCJ) $(JC1FLAGS) $(LDFLAGS) \
-o gij
gij_LDADD = gij.lo libgcj.la \
$(GCLIBS) $(THREADLIBS) $(ZLIBS) -L$(here)/.libs
gij_DEPENDENCIES = gij.lo \
$(GCDEPS) $(THREADDEPS) $(ZDEPS) libgcj.la libgcj.spec
gen_from_JIS_SOURCES =
EXTRA_gen_from_JIS_SOURCES = $(srcdir)/$(CONVERT_DIR)/gen-from-JIS.c \
$(srcdir)/$(CONVERT_DIR)/make-trie.c \
@ -294,6 +314,13 @@ java/awt/peer/WindowPeer.java
built_java_source_files = java/lang/ConcreteProcess.java
ordinary_java_source_files = $(convert_source_files) \
gnu/gcj/runtime/MethodInvocation.java \
gnu/gcj/util/path/SearchPath.java \
gnu/gcj/util/path/PathEntry.java \
gnu/gcj/util/path/DirectoryPathEntry.java \
gnu/gcj/util/path/ZipPathEntry.java \
gnu/gcj/util/path/URLPathEntry.java \
gnu/gcj/util/path/CacheEntry.java \
gnu/gcj/text/BaseBreakIterator.java \
gnu/gcj/text/CharacterBreakIterator.java \
gnu/gcj/text/LineBreakIterator.java \
@ -372,6 +399,7 @@ java/lang/ClassCastException.java \
java/lang/ClassCircularityError.java \
java/lang/ClassFormatError.java \
java/lang/ClassLoader.java \
java/lang/VMClassLoader.java \
java/lang/ClassNotFoundException.java \
java/lang/CloneNotSupportedException.java \
java/lang/Cloneable.java \
@ -569,6 +597,7 @@ java/io/natFile.cc \
java/io/natFileDescriptor.cc \
java/lang/natCharacter.cc \
java/lang/natClass.cc \
java/lang/natClassLoader.cc \
java/lang/natConcreteProcess.cc \
java/lang/natDouble.cc \
java/lang/natFirstThread.cc \
@ -655,13 +684,15 @@ DEFS = @DEFS@ -I. -I$(srcdir) -I./include
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libgcj_la_OBJECTS = prims.lo jni.lo exception.lo
@NATIVE_TRUE@bin_PROGRAMS = jv-convert$(EXEEXT)
libgcj_la_OBJECTS = prims.lo jni.lo exception.lo resolve.lo \
defineclass.lo interpret.lo
@NATIVE_TRUE@bin_PROGRAMS = jv-convert$(EXEEXT) gij$(EXEEXT)
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@noinst_PROGRAMS = \
@NATIVE_TRUE@@MAINTAINER_MODE_TRUE@gen-from-JIS$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
jv_convert_OBJECTS =
gij_OBJECTS =
gen_from_JIS_OBJECTS =
gen_from_JIS_LDFLAGS =
CXXFLAGS = @CXXFLAGS@
@ -688,9 +719,9 @@ GZIP_ENV = --best
DIST_SUBDIRS = testsuite
DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/$(srcdir)/$(CONVERT_DIR)/make-trie.P .deps/boehm.P \
.deps/exception.P .deps/gnu/gcj/RawData.P \
.deps/gnu/gcj/convert/BytesToUnicode.P .deps/gnu/gcj/convert/Convert.P \
.deps/gnu/gcj/convert/Input_8859_1.P \
.deps/defineclass.P .deps/exception.P .deps/gij.P \
.deps/gnu/gcj/RawData.P .deps/gnu/gcj/convert/BytesToUnicode.P \
.deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/Input_8859_1.P \
.deps/gnu/gcj/convert/Input_EUCJIS.P \
.deps/gnu/gcj/convert/Input_JavaSrc.P \
.deps/gnu/gcj/convert/Input_SJIS.P .deps/gnu/gcj/convert/Input_UTF8.P \
@ -703,6 +734,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/gcj/protocol/file/Handler.P \
.deps/gnu/gcj/protocol/http/Connection.P \
.deps/gnu/gcj/protocol/http/Handler.P \
.deps/gnu/gcj/runtime/MethodInvocation.P \
.deps/gnu/gcj/text/BaseBreakIterator.P \
.deps/gnu/gcj/text/CharacterBreakIterator.P \
.deps/gnu/gcj/text/LineBreakIterator.P \
@ -711,6 +743,12 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/gnu/gcj/text/SentenceBreakIterator.P \
.deps/gnu/gcj/text/WordBreakIterator.P \
.deps/gnu/gcj/util/EnumerationChain.P \
.deps/gnu/gcj/util/path/CacheEntry.P \
.deps/gnu/gcj/util/path/DirectoryPathEntry.P \
.deps/gnu/gcj/util/path/PathEntry.P \
.deps/gnu/gcj/util/path/SearchPath.P \
.deps/gnu/gcj/util/path/URLPathEntry.P \
.deps/gnu/gcj/util/path/ZipPathEntry.P .deps/interpret.P \
.deps/java/io/BufferedInputStream.P \
.deps/java/io/BufferedOutputStream.P .deps/java/io/BufferedReader.P \
.deps/java/io/BufferedWriter.P .deps/java/io/ByteArrayInputStream.P \
@ -788,8 +826,9 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/lang/Throwable.P .deps/java/lang/UnknownError.P \
.deps/java/lang/UnsatisfiedLinkError.P \
.deps/java/lang/UnsupportedOperationException.P \
.deps/java/lang/VerifyError.P .deps/java/lang/VirtualMachineError.P \
.deps/java/lang/Void.P .deps/java/lang/dtoa.P .deps/java/lang/e_acos.P \
.deps/java/lang/VMClassLoader.P .deps/java/lang/VerifyError.P \
.deps/java/lang/VirtualMachineError.P .deps/java/lang/Void.P \
.deps/java/lang/dtoa.P .deps/java/lang/e_acos.P \
.deps/java/lang/e_asin.P .deps/java/lang/e_atan2.P \
.deps/java/lang/e_exp.P .deps/java/lang/e_fmod.P \
.deps/java/lang/e_log.P .deps/java/lang/e_pow.P \
@ -872,9 +911,9 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/util/zip/ZipException.P .deps/java/util/zip/ZipFile.P \
.deps/java/util/zip/ZipInputStream.P \
.deps/java/util/zip/ZipOutputStream.P .deps/jni.P .deps/no-threads.P \
.deps/nogc.P .deps/posix-threads.P .deps/prims.P
SOURCES = $(libgcj_la_SOURCES) $(EXTRA_libgcj_la_SOURCES) $(jv_convert_SOURCES) $(EXTRA_jv_convert_SOURCES) $(gen_from_JIS_SOURCES) $(EXTRA_gen_from_JIS_SOURCES)
OBJECTS = $(libgcj_la_OBJECTS) $(jv_convert_OBJECTS) $(gen_from_JIS_OBJECTS)
.deps/nogc.P .deps/posix-threads.P .deps/prims.P .deps/resolve.P
SOURCES = $(libgcj_la_SOURCES) $(EXTRA_libgcj_la_SOURCES) $(jv_convert_SOURCES) $(EXTRA_jv_convert_SOURCES) $(gij_SOURCES) $(EXTRA_gij_SOURCES) $(gen_from_JIS_SOURCES) $(EXTRA_gen_from_JIS_SOURCES)
OBJECTS = $(libgcj_la_OBJECTS) $(jv_convert_OBJECTS) $(gij_OBJECTS) $(gen_from_JIS_OBJECTS)
all: all-redirect
.SUFFIXES:
@ -1022,6 +1061,10 @@ jv-convert$(EXEEXT): $(jv_convert_OBJECTS) $(jv_convert_DEPENDENCIES)
@rm -f jv-convert$(EXEEXT)
$(jv_convert_LINK) $(jv_convert_LDFLAGS) $(jv_convert_OBJECTS) $(jv_convert_LDADD) $(LIBS)
gij$(EXEEXT): $(gij_OBJECTS) $(gij_DEPENDENCIES)
@rm -f gij$(EXEEXT)
$(gij_LINK) $(gij_LDFLAGS) $(gij_OBJECTS) $(gij_LDADD) $(LIBS)
gen-from-JIS$(EXEEXT): $(gen_from_JIS_OBJECTS) $(gen_from_JIS_DEPENDENCIES)
@rm -f gen-from-JIS$(EXEEXT)
$(LINK) $(gen_from_JIS_LDFLAGS) $(gen_from_JIS_OBJECTS) $(gen_from_JIS_LDADD) $(LIBS)
@ -1451,6 +1494,16 @@ java/lang/reflect/Method.h: java/lang/reflect/Method.class libgcj.zip
-friend 'java::lang::Class;' \
$(basename $<)
java/lang/VMClassLoader.h: java/lang/VMClassLoader.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'java::lang::ClassLoader;' \
$(basename $<)
gnu/gcj/runtime/MethodInvocation.h: gnu/gcj/runtime/MethodInvocation.class libgcj.zip
$(GCJH) -classpath $(top_builddir) \
-friend 'class _Jv_InterpMethod;' \
$(basename $<)
maintainer-check: libgcj.la
$(NM) .libs/libgcj.a | grep ' T ' \
| grep -v '4java' \

View file

@ -1,3 +1,7 @@
New in libgcj X.XX:
* libgcj now includes a bytecode interpreter.
New in libgcj 2.95:
* First public release

View file

@ -10,9 +10,10 @@ Eric Christopher echristo@cygnus.com
Franz Sirl Franz.Sirl-kernel@lauterbach.com
Geoff Berry gcb@gnu.org
Gilles Zunino Gilles.Zunino@hei.fr
Per Bothner per@bother.com
Kresten Krab Thorup krab@gnu.org
Per Bothner per@bothner.com
Rainer Orth ro@TechFak.Uni-Bielefeld.DE
Stu Grossman grossman@cygnus.com
Stu Grossman grossman@juniper.com
Tom Tromey tromey@cygnus.com
Urban Widmark urban@svenskatest.se
Warren Levy warrenl@cygnus.com

View file

@ -93,3 +93,6 @@
#undef HAVE_READDIR_R
#undef HAVE_GETHOSTBYNAME_R
#undef HAVE_GETHOSTBYADDR_R
/* Define if you want a bytecode interpreter. */
#undef INTERPRETER

View file

@ -16,6 +16,7 @@ details. */
#include <java/lang/Class.h>
#include <jvm.h>
#include <java-field.h>
#include <java-interp.h>
// We need to include gc_priv.h. However, it tries to include
// config.h if it hasn't already been included. So we force the
@ -97,8 +98,14 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
{
jclass c = (jclass) addr;
#if 0
// The next field should probably not be marked, since this is
// only used in the class hash table. Marking this field
// basically prohibits class unloading. --Kresten
w = (word) c->next;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c2label);
#endif
w = (word) c->name;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c3label);
w = (word) c->superclass;
@ -109,12 +116,23 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c5label);
}
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (c))
{
w = (word) c->constants.tags;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c5alabel);
w = (word) c->constants.data;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c5blabel);
}
#endif
// If the class is an array, then the methods field holds a
// pointer to the element class. If the class is primitive,
// then the methods field holds a pointer to the array class.
w = (word) c->methods;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c6label);
if (! c->isArray() && ! c->isPrimitive())
{
// Scan each method in the cases where `methods' really
@ -127,7 +145,19 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
w = (word) c->methods[i].signature;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c,
cm2label);
// FIXME: `ncode' entry?
#ifdef INTERPRETER
// The interpreter installs a heap-allocated
// trampoline here, so we'll mark it.
if (_Jv_IsInterpretedClass (c))
{
w = (word) c->methods[i].ncode;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c,
cm3label);
}
#endif
}
}
@ -136,12 +166,34 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c8label);
for (int i = 0; i < c->field_count; ++i)
{
_Jv_Field* field = &c->fields[i];
#ifndef COMPACT_FIELDS
w = (word) c->fields[i].name;
w = (word) field->name;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c8alabel);
#endif
w = (word) c->fields[i].type;
w = (word) field->type;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c8blabel);
// For the interpreter, we also need to mark the memory
// containing static members
if (field->flags & 0x0008)
{
w = (word) field->u.addr;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, c8clabel);
// also, if the static member is a reference,
// mark also the value pointed to. We check for isResolved
// since marking can happen before memory is allocated for
// static members.
if (JvFieldIsRef (field) && field->isResolved())
{
jobject val = *(jobject*) field->u.addr;
w = (word) val;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit,
c, c8elabel);
}
}
}
w = (word) c->vtable;
@ -155,6 +207,28 @@ _Jv_MarkObj (void *addr, void *msp, void *msl, void * /*env*/)
}
w = (word) c->loader;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, c, cBlabel);
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (c))
{
_Jv_InterpClass* ic = (_Jv_InterpClass*)c;
w = (word) ic->interpreted_methods;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, ic, cElabel);
for (int i = 0; i < c->method_count; i++)
{
w = (word) ic->interpreted_methods[i];
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, ic, \
cFlabel);
}
w = (word) ic->field_initializers;
MAYBE_MARK (w, mark_stack_ptr, mark_stack_limit, ic, cGlabel);
}
#endif
}
else
{

409
libjava/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -42,6 +42,17 @@ AC_ARG_ENABLE(libgcj-debug,
AC_DEFINE(DEBUG)
fi)
dnl See if the user has the enterpreter included.
AC_ARG_ENABLE(interpreter,
[ --enable-interpreter Enable interpreter],
if test "$enable_interpreter" = yes; then
AC_DEFINE(INTERPRETER)
fi)
dnl This becomes -lffi if the interpreter is enables
INTERPSPEC=
AC_SUBST(INTERPSPEC)
dnl If the target is an eCos system, use the appropriate eCos
dnl I/O routines.
dnl FIXME: this should not be a local option but a global target
@ -447,6 +458,10 @@ else
])
SYSTEMSPEC="$SYSTEMSPEC $gcj_cv_lib_sockets"
if test "$enable_interpreter" = yes; then
INTERPSPEC=
fi
if test "$with_system_zlib" = yes; then
AC_CHECK_LIB(z, deflate, ZLIBSPEC=-lz, ZLIBSPEC=-lzgcj)
else

1556
libjava/defineclass.cc Normal file

File diff suppressed because it is too large Load diff

27
libjava/gij.cc Normal file
View file

@ -0,0 +1,27 @@
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
#include <jvm.h>
#include <cni.h>
#include <stdio.h>
#include <java/lang/System.h>
#include <java/util/Properties.h>
int main (int argc, const char **argv)
{
if (argc < 2)
{
printf ("usage: %s <class name> args\n", argv[0]);
exit (1);
}
JvRunMain (0, argc, argv);
}

View file

@ -0,0 +1,32 @@
// MethodInvocation.java - wrapper used by the interpreter.
// (the native method is implemented in interpret.cc)
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.runtime;
import gnu.gcj.RawData;
final class MethodInvocation {
private static Throwable continue0 (RawData meth, RawData inv)
{
try {
continue1 (meth, inv);
} catch (Throwable ex) {
return ex;
}
return null;
}
private static native void continue1 (RawData meth, RawData inv);
}

View file

@ -0,0 +1,65 @@
// CacheEntry.java -- directory cache
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final class CacheEntry {
String dir;
String[] files;
long time;
CacheEntry (String d)
{
dir = d;
files = new File(dir).list();
time = System.currentTimeMillis ();
}
void touch ()
{
time = System.currentTimeMillis ();
}
final long EXPIRATION_TIME_MS = 1000;
boolean is_old () {
return (System.currentTimeMillis () - time) > EXPIRATION_TIME_MS;
}
public int hashCode () { return dir.hashCode(); }
boolean contains (String file) {
if (files == null)
return false;
int index = file.lastIndexOf(SearchPath.file_seperator_char);
String f;
if (index == -1)
f = file;
else
f = file.substring (index+1);
for (int i = 0; i < files.length; i++)
{
if (f.equals (files[i])) return true;
}
return false;
}
}

View file

@ -0,0 +1,136 @@
// DirectoryPathEntry.java -- search path element for directories
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final class DirectoryPathEntry extends PathEntry
{
final File dir;
final String base_canon;
public String toString () { return base_canon; }
DirectoryPathEntry (File f)
throws java.io.IOException
{
if (!f.isAbsolute ())
throw new IllegalArgumentException ();
dir = f;
base_canon = dir.getCanonicalPath ();
}
/*
* We maintain a cache of files, so that we
* can avoid many calls to stat(), which are
* very expensive.
*
* seen_cache contains (as keys) the directories
* which we have visited so far. The values are
* instances of CacheEntry, containing a time stamp,
* and a list of files in that directory.
*
*/
private Hashtable seen_cache = new Hashtable ();
private boolean in_cache (File f)
{
String rel_dir = f.getParent ();
CacheEntry ent;
if (rel_dir == null)
throw new IllegalArgumentException ();
ent = (CacheEntry) seen_cache.get (rel_dir);
if (ent == null)
{
ent = new CacheEntry (rel_dir);
seen_cache.put (rel_dir, ent);
}
if (ent.contains (f.getPath ()))
{
return true;
}
if ( ent.is_old () )
{
if (f.exists ())
{
seen_cache.remove (rel_dir);
return true;
}
else
{
ent.touch ();
}
}
return false;
}
URL getURL (String file) {
try {
File f = new File((new File (dir, file).getCanonicalPath ()));
if (! f.getCanonicalPath ().startsWith (base_canon))
throw new IllegalArgumentException (file);
if (in_cache (f))
return new URL ("file", "", f.getPath ());
else
return null;
} catch (IOException x) {
return null;
}
}
InputStream getStream (String file) {
try {
File f = new File((new File (dir, file)).getCanonicalPath ());
if (! f.getCanonicalPath ().startsWith (base_canon))
throw new IllegalArgumentException (file);
if (in_cache (f))
return new FileInputStream (f);
else
return null;
} catch (IOException x) {
return null;
}
}
byte[] getBytes (String file) {
File f = new File (dir, file);
try {
if (in_cache (f))
return readbytes (new FileInputStream (f),
(int) f.length ());
else
return null;
} catch (IOException x) {
return null;
}
}
}

View file

@ -0,0 +1,55 @@
// PathEntry.java -- abstract element of search paths
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
abstract class PathEntry {
abstract URL getURL (String file);
abstract InputStream getStream (String file);
abstract byte[] getBytes (String file);
/**
* Utility routine like InputStream.read(byte[], 0, len), but will
* read fully, even if all the data is not available at once.
*/
protected static byte[] readbytes (InputStream is, int length)
{
try {
byte[] data = new byte[length];
int read;
int off = 0;
while (off != length)
{
read = is.read (data, off, (int) (length-off));
if (read == -1)
return null;
off += read;
}
return data;
} catch (IOException x) {
return null;
}
}
}

View file

@ -0,0 +1,205 @@
// SearchPath.java -- generic search path utility
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final public class SearchPath {
final static String path_seperator
= System.getProperty ("path.separator");
final static char path_seperator_char
= path_seperator.charAt (0);
final static String file_seperator
= System.getProperty ("file.separator");
final static char file_seperator_char
= file_seperator.charAt (0);
private Vector path;
/**
* Constructs a SearchPath object, given a system path.
* The system path is expected to be seperated by the string
* defined by the <code>path.seperator</code> property.
* (<code>":"</code> on unix, <code>;</code> on Windows, etc.).
* The path may contain names of directories, or names of
* .zip or .jar files. Elements that are neither of these
* are ignored.
* @param sys_path the search path
*/
SearchPath (String sys_path)
{
StringTokenizer st = new StringTokenizer (sys_path, path_seperator);
init (st);
}
/**
* Constructs a SearchPath object, given a Vector of
* <code>String</code>, <code>File</code> or <code>URL</code>
* objects.
* The path may contain names of directories, or names of
* .zip or .jar files. Elements that are neither of these
* are ignored.
* @param p the vector of search path elements
*/
SearchPath (Vector p)
{
init (p.elements ());
}
public URL getURL (String element)
{
URL result;
Enumeration e = path.elements ();
while (e.hasMoreElements ())
{
PathEntry ent = (PathEntry) e.nextElement ();
result = ent.getURL (element);
if (result != null)
{
return result;
}
}
return null;
}
public InputStream getStream (String element)
{
InputStream result;
Enumeration e = path.elements ();
while (e.hasMoreElements ())
{
PathEntry ent = (PathEntry) e.nextElement ();
result = ent.getStream (element);
if (result != null)
{
return result;
}
}
return null;
}
public byte[] getBytes (String element)
{
byte[] result;
Enumeration e = path.elements ();
while (e.hasMoreElements ())
{
PathEntry ent = (PathEntry) e.nextElement ();
result = ent.getBytes (element);
if (result != null)
{
System.out.println ("loading " + ent
+ "(" + element + ")");
return result;
}
}
return null;
}
private void init (Enumeration st)
{
path = new Vector ();
while (st.hasMoreElements ())
{
Object e = st.nextElement ();
String elem;
File efile;
if (e instanceof URL)
{
path.addElement (new URLPathEntry ((URL) e));
continue;
}
if (e instanceof File)
{
efile = (File) e;
elem = efile.getPath ();
}
else if (e instanceof String)
{
elem = (String) e;
efile = new File (elem);
}
else
throw new IllegalArgumentException ();
// make sure it is absolute, so we won't get
// trouble if the cwd is changed...
if (! efile.isAbsolute ())
efile = new File (efile.getAbsolutePath ());
if (efile.isDirectory ())
{
try {
path.addElement(new DirectoryPathEntry (efile));
} catch (IOException x) {
/* ignore for now */
}
}
else if (efile.isFile ())
{
int ext = elem.lastIndexOf ('.');
if (ext == -1)
continue;
if (!elem.substring(ext+1).equalsIgnoreCase("zip"))
continue;
ZipPathEntry zpe = null;
try {
zpe = new ZipPathEntry (efile);
} catch (ZipException zx) {
System.err.println ("SearchPath::ZipException");
zpe = null;
} catch (MalformedURLException mx) {
System.err.println ("SearchPath::URLException");
zpe = null;
} catch (IOException iox) {
System.err.println ("SearchPath::IOException");
zpe = null;
}
if (zpe != null) path.addElement (zpe);
}
}
}
}

View file

@ -0,0 +1,67 @@
// URLPathEntry.java -- search path element for URL's
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final class URLPathEntry extends PathEntry {
final URL base;
URLPathEntry (URL f) {
base = f;
}
public String toString () { return base.toString (); }
URL getURL (String file) {
try {
URL res = new URL (base, file);
InputStream is = res.openStream (); // exc if not found
is.close ();
return res;
} catch (java.io.IOException x) {
return null;
}
}
InputStream getStream (String file) {
try {
URL res = new URL (base, file);
return res.openStream ();
} catch (java.io.IOException x) {
return null;
}
}
byte[] getBytes (String file) {
try {
URL res = new URL (base, file);
URLConnection conn = res.openConnection ();
int len = conn.getContentLength ();
if (len == -1) return null;
return readbytes (conn.getInputStream (), len);
} catch (java.io.IOException x) {
return null;
}
}
}

View file

@ -0,0 +1,86 @@
// ZipPathEntry.java -- search path element for directories
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package gnu.gcj.util.path;
import java.util.*;
import java.util.zip.*;
import java.io.*;
import java.net.*;
final class ZipPathEntry extends PathEntry {
final ZipFile zip;
final URL file;
public String toString () { return zip.getName (); }
ZipPathEntry (File f)
throws MalformedURLException, ZipException, IOException
{
file = new URL ("file", "", f.getPath ());
zip = new ZipFile (f);
zip.readDirectory ();
}
/*
The url for a zip-file resource is,
<code>file:///path/file.zip#name</code>
Then, it is URLConnection's problem to handle that.
*/
URL getURL (String f) {
ZipEntry ent = zip.getEntry (f);
try {
if (ent != null)
return new URL (file, "#"+f);
else
return null;
} catch (IOException x) {
return null;
}
}
InputStream getStream (String f) {
ZipEntry ent = zip.getEntry (f);
try {
if (ent != null)
return zip.getInputStream (ent);
else
return null;
} catch (IOException x) {
return null;
}
}
byte[] getBytes (String f) {
ZipEntry ent = zip.getEntry (f);
try {
if (ent != null)
return readbytes (zip.getInputStream (ent),
(int) ent.getSize ());
else
return null;
} catch (IOException x) {
return null;
}
}
}

View file

@ -106,6 +106,9 @@
#undef HAVE_GETHOSTBYNAME_R
#undef HAVE_GETHOSTBYADDR_R
/* Define if you want a bytecode interpreter. */
#undef INTERPRETER
/* Define if you have the access function. */
#undef HAVE_ACCESS

View file

@ -0,0 +1,173 @@
// java-cpool.h - Constant pool parsing header. -*- c++ -*-
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef __JAVA_CPOOL_H__
#define __JAVA_CPOOL_H__
#include <javaprims.h>
// we rename these, to avoid polluting the name space
#define JV_CONSTANT_Undefined (0L)
#define JV_CONSTANT_Utf8 (1L)
#define JV_CONSTANT_Unicode (2L)
#define JV_CONSTANT_Integer (3L)
#define JV_CONSTANT_Float (4L)
#define JV_CONSTANT_Long (5L)
#define JV_CONSTANT_Double (6L)
#define JV_CONSTANT_Class (7L)
#define JV_CONSTANT_String (8L)
#define JV_CONSTANT_Fieldref (9L)
#define JV_CONSTANT_Methodref (10L)
#define JV_CONSTANT_InterfaceMethodref (11L)
#define JV_CONSTANT_NameAndType (12L)
#define JV_CONSTANT_ResolvedFlag (16L)
#define JV_CONSTANT_ResolvedString (16L | 8L)
#define JV_CONSTANT_ResolvedClass (16L | 7L)
/* We use the following two operations uniformly for all put/get operations
* in the runtime system (constant pool & stack), to assure that we keep
* everything in the same format. The idea is, that these should be inlined
* away, into just a simple store (for small data types, and a pair of stores
* if double or long has alignment greater than void *. On an 64-bit
* architecture, all operations should be simple stores; on a 32-bit
* architecture it depends on the alignment requirement for the specific
* type. */
template <class T>
static inline void _Jv_put (void *dst, T value)
{
#if 0
if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*))
{
jint *v_dst = (jint*)(dst);
jint *v_src = (jint*)&value;
v_dst[0] = v_src[0];
v_dst[1] = v_src[1];
}
else
#endif
{
*((T*) (dst)) = value;
}
}
template <class T>
static inline T _Jv_get (void *src)
{
#if 0
if (sizeof (T) == 8 && __alignof__ (T) > __alignof__ (void*))
{
T value;
jint *v_dst = (jint*)&value;
jint *v_src = (jint*)src;
v_dst[0] = v_src[0];
v_dst[1] = v_src[1];
return value;
}
else
#endif
{
return *((T*) (src));
}
}
/** needed to keep the CONSTANT_XXXRef & CONSTANT_NameAndType entries */
extern inline void
_Jv_storeIndexes (void **data,
_Jv_ushort index0,
_Jv_ushort index1)
{
// accomodate 64bit machines...
if (sizeof (void*) == (2 * sizeof (jint)))
{
((jint*)data)[0] = index0;
((jint*)data)[1] = index0;
}
else
{
_Jv_put<jint>(data, ((jint)index0 << 16) | (jint)index1);
}
}
extern inline void
_Jv_loadIndexes (const void **data,
_Jv_ushort& index0,
_Jv_ushort& index1)
{
if (sizeof (void*) == (2*sizeof (jint)))
{
index0 = ((jint*)data)[0];
index0 = ((jint*)data)[1];
}
else
{
jint udata = _Jv_get<jint>(data);
_Jv_uint uindex0 = ((udata >> 16) & 0xffff);
_Jv_uint uindex1 = udata & 0xffff;
index0 = uindex0;
index1 = uindex1;
}
}
extern inline void
_Jv_storeFloat (void **data, jfloat f)
{
_Jv_put<jfloat>(data, f);
}
extern inline jfloat
_Jv_loadFloat (void **data)
{
return _Jv_get<jfloat>(data);
}
extern inline void
_Jv_storeInt (void **data, jint i)
{
_Jv_put<jint>(data, i);
}
extern inline jint
_Jv_loadInt (void **data)
{
return _Jv_get<jint>(data);
}
extern inline void
_Jv_storeLong (void **data, jlong l)
{
return _Jv_put<jlong>(data, l);
}
extern inline jlong
_Jv_loadLong (void **data)
{
return _Jv_get<jlong>(data);
}
extern inline void
_Jv_storeDouble (void **data, jdouble d)
{
_Jv_put<jdouble>(data, d);
}
extern inline jdouble
_Jv_loadDouble (void **data)
{
return _Jv_get<jdouble> (data);
}
#endif /* __JAVA_CPOOL_H__ */

View file

@ -53,7 +53,18 @@ struct _Jv_Field
jfieldID getNextInstanceField () { return this + 1; }
jboolean isRef () { return ! isResolved () || ! type->isPrimitive (); }
jboolean isRef ()
{
if (!isResolved ())
{
char first = ((_Jv_Utf8Const*)type)->data[0];
return first == '[' || first == 'L';
}
else
{
return ! type->isPrimitive ();
}
}
// FIXME - may need to mask off internal flags.
int getModifiers() { return flags; }

View file

@ -0,0 +1,247 @@
// java-insns.h - Instruction encodings. This is -*- c++ -*-
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
static const int op_nop = 0x00;
static const int op_aconst_null = 0x01;
static const int op_iconst_m1 = 0x02;
static const int op_iconst_0 = 0x03;
static const int op_iconst_1 = 0x04;
static const int op_iconst_2 = 0x05;
static const int op_iconst_3 = 0x06;
static const int op_iconst_4 = 0x07;
static const int op_iconst_5 = 0x08;
static const int op_lconst_0 = 0x09;
static const int op_lconst_1 = 0x0a;
static const int op_fconst_0 = 0x0b;
static const int op_fconst_1 = 0x0c;
static const int op_fconst_2 = 0x0d;
static const int op_dconst_0 = 0x0e;
static const int op_dconst_1 = 0x0f;
static const int op_bipush = 0x10;
static const int op_sipush = 0x11;
static const int op_ldc = 0x12;
static const int op_ldc_w = 0x13;
static const int op_ldc2_w = 0x14;
static const int op_iload = 0x15;
static const int op_lload = 0x16;
static const int op_fload = 0x17;
static const int op_dload = 0x18;
static const int op_aload = 0x19;
static const int op_iload_0 = 0x1a;
static const int op_iload_1 = 0x1b;
static const int op_iload_2 = 0x1c;
static const int op_iload_3 = 0x1d;
static const int op_lload_0 = 0x1e;
static const int op_lload_1 = 0x1f;
static const int op_lload_2 = 0x20;
static const int op_lload_3 = 0x21;
static const int op_fload_0 = 0x22;
static const int op_fload_1 = 0x23;
static const int op_fload_2 = 0x24;
static const int op_fload_3 = 0x25;
static const int op_dload_0 = 0x26;
static const int op_dload_1 = 0x27;
static const int op_dload_2 = 0x28;
static const int op_dload_3 = 0x29;
static const int op_aload_0 = 0x2a;
static const int op_aload_1 = 0x2b;
static const int op_aload_2 = 0x2c;
static const int op_aload_3 = 0x2d;
static const int op_iaload = 0x2e;
static const int op_laload = 0x2f;
static const int op_faload = 0x30;
static const int op_daload = 0x31;
static const int op_aaload = 0x32;
static const int op_baload = 0x33;
static const int op_caload = 0x34;
static const int op_saload = 0x35;
static const int op_istore = 0x36;
static const int op_lstore = 0x37;
static const int op_fstore = 0x38;
static const int op_dstore = 0x39;
static const int op_astore = 0x3a;
static const int op_istore_0 = 0x3b;
static const int op_istore_1 = 0x3c;
static const int op_istore_2 = 0x3d;
static const int op_istore_3 = 0x3e;
static const int op_lstore_0 = 0x3f;
static const int op_lstore_1 = 0x40;
static const int op_lstore_2 = 0x41;
static const int op_lstore_3 = 0x42;
static const int op_fstore_0 = 0x43;
static const int op_fstore_1 = 0x44;
static const int op_fstore_2 = 0x45;
static const int op_fstore_3 = 0x46;
static const int op_dstore_0 = 0x47;
static const int op_dstore_1 = 0x48;
static const int op_dstore_2 = 0x49;
static const int op_dstore_3 = 0x4a;
static const int op_astore_0 = 0x4b;
static const int op_astore_1 = 0x4c;
static const int op_astore_2 = 0x4d;
static const int op_astore_3 = 0x4e;
static const int op_iastore = 0x4f;
static const int op_lastore = 0x50;
static const int op_fastore = 0x51;
static const int op_dastore = 0x52;
static const int op_aastore = 0x53;
static const int op_bastore = 0x54;
static const int op_castore = 0x55;
static const int op_sastore = 0x56;
static const int op_pop = 0x57;
static const int op_pop2 = 0x58;
static const int op_dup = 0x59;
static const int op_dup_x1 = 0x5a;
static const int op_dup_x2 = 0x5b;
static const int op_dup2 = 0x5c;
static const int op_dup2_x1 = 0x5d;
static const int op_dup2_x2 = 0x5e;
static const int op_swap = 0x5f;
static const int op_iadd = 0x60;
static const int op_ladd = 0x61;
static const int op_fadd = 0x62;
static const int op_dadd = 0x63;
static const int op_isub = 0x64;
static const int op_lsub = 0x65;
static const int op_fsub = 0x66;
static const int op_dsub = 0x67;
static const int op_imul = 0x68;
static const int op_lmul = 0x69;
static const int op_fmul = 0x6a;
static const int op_dmul = 0x6b;
static const int op_idiv = 0x6c;
static const int op_ldiv = 0x6d;
static const int op_fdiv = 0x6e;
static const int op_ddiv = 0x6f;
static const int op_irem = 0x70;
static const int op_lrem = 0x71;
static const int op_frem = 0x72;
static const int op_drem = 0x73;
static const int op_ineg = 0x74;
static const int op_lneg = 0x75;
static const int op_fneg = 0x76;
static const int op_dneg = 0x77;
static const int op_ishl = 0x78;
static const int op_lshl = 0x79;
static const int op_ishr = 0x7a;
static const int op_lshr = 0x7b;
static const int op_iushr = 0x7c;
static const int op_lushr = 0x7d;
static const int op_iand = 0x7e;
static const int op_land = 0x7f;
static const int op_ior = 0x80;
static const int op_lor = 0x81;
static const int op_ixor = 0x82;
static const int op_lxor = 0x83;
static const int op_iinc = 0x84;
static const int op_i2l = 0x85;
static const int op_i2f = 0x86;
static const int op_i2d = 0x87;
static const int op_l2i = 0x88;
static const int op_l2f = 0x89;
static const int op_l2d = 0x8a;
static const int op_f2i = 0x8b;
static const int op_f2l = 0x8c;
static const int op_f2d = 0x8d;
static const int op_d2i = 0x8e;
static const int op_d2l = 0x8f;
static const int op_d2f = 0x90;
static const int op_i2b = 0x91;
static const int op_i2c = 0x92;
static const int op_i2s = 0x93;
static const int op_lcmp = 0x94;
static const int op_fcmpl = 0x95;
static const int op_fcmpg = 0x96;
static const int op_dcmpl = 0x97;
static const int op_dcmpg = 0x98;
static const int op_ifeq = 0x99;
static const int op_ifne = 0x9a;
static const int op_iflt = 0x9b;
static const int op_ifge = 0x9c;
static const int op_ifgt = 0x9d;
static const int op_ifle = 0x9e;
static const int op_if_icmpeq = 0x9f;
static const int op_if_icmpne = 0xa0;
static const int op_if_icmplt = 0xa1;
static const int op_if_icmpge = 0xa2;
static const int op_if_icmpgt = 0xa3;
static const int op_if_icmple = 0xa4;
static const int op_if_acmpeq = 0xa5;
static const int op_if_acmpne = 0xa6;
static const int op_goto = 0xa7;
static const int op_jsr = 0xa8;
static const int op_ret = 0xa9;
static const int op_tableswitch = 0xaa;
static const int op_lookupswitch = 0xab;
static const int op_ireturn = 0xac;
static const int op_lreturn = 0xad;
static const int op_freturn = 0xae;
static const int op_dreturn = 0xaf;
static const int op_areturn = 0xb0;
static const int op_return = 0xb1;
static const int op_getstatic = 0xb2;
static const int op_putstatic = 0xb3;
static const int op_getfield = 0xb4;
static const int op_putfield = 0xb5;
static const int op_invokevirtual = 0xb6;
static const int op_invokespecial = 0xb7;
static const int op_invokestatic = 0xb8;
static const int op_invokeinterface = 0xb9;
static const int op_xxxunusedxxx1 = 0xba;
static const int op_new = 0xbb;
static const int op_newarray = 0xbc;
static const int op_anewarray = 0xbd;
static const int op_arraylength = 0xbe;
static const int op_athrow = 0xbf;
static const int op_checkcast = 0xc0;
static const int op_instanceof = 0xc1;
static const int op_monitorenter = 0xc2;
static const int op_monitorexit = 0xc3;
static const int op_wide = 0xc4;
static const int op_multianewarray = 0xc5;
static const int op_ifnull = 0xc6;
static const int op_ifnonnull = 0xc7;
static const int op_goto_w = 0xc8;
static const int op_jsr_w = 0xc9;
// new opcodes
static const int op_putfield_1 = 0xca;
static const int op_putfield_2 = 0xcb;
static const int op_putfield_4 = 0xcd;
static const int op_putfield_8 = 0xce;
static const int op_putfield_a = 0xcf;
static const int op_putstatic_1 = 0xd0;
static const int op_putstatic_2 = 0xd1;
static const int op_putstatic_4 = 0xd2;
static const int op_putstatic_8 = 0xd3;
static const int op_putstatic_a = 0xd4;
static const int op_getfield_1 = 0xd5;
static const int op_getfield_2s = 0xd6;
static const int op_getfield_2u = 0xd7;
static const int op_getfield_4 = 0xd8;
static const int op_getfield_8 = 0xd9;
static const int op_getfield_a = 0xda;
static const int op_getstatic_1 = 0xdb;
static const int op_getstatic_2s = 0xdc;
static const int op_getstatic_2u = 0xdd;
static const int op_getstatic_4 = 0xde;
static const int op_getstatic_8 = 0xdf;
static const int op_getstatic_a = 0xe0;
static const int op_invokefinal = 0xe1;
static const int op_invokevtable = 0xe2;

View file

@ -0,0 +1,172 @@
// java-interp.h - Header file for the bytecode interpreter. -*- c++ -*-
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#ifndef __JAVA_INTERP_H__
#define __JAVA_INTERP_H__
#include <config.h>
#include <jvm.h>
#include <java-cpool.h>
#ifdef INTERPRETER
#pragma interface
#include <java/lang/Class.h>
#include <java/lang/ClassLoader.h>
#include <gnu/gcj/runtime/MethodInvocation.h>
extern "C" {
#include <ffi.h>
}
extern inline jboolean
_Jv_IsInterpretedClass (jclass c)
{
return (c->loader != 0);
}
struct _Jv_ResolvedMethod;
void _Jv_VerifyFieldSignature (_Jv_Utf8Const*sig);
void _Jv_VerifyMethodSignature (_Jv_Utf8Const*sig);
void _Jv_VerifyClassName (unsigned char* ptr, _Jv_ushort length);
void _Jv_VerifyClassName (_Jv_Utf8Const *name);
void _Jv_VerifyIdentifier (_Jv_Utf8Const *);
bool _Jv_ClassNameSamePackage (_Jv_Utf8Const *name1, _Jv_Utf8Const *name2);
void _Jv_DefineClass (jclass, jbyteArray, jint, jint);
void _Jv_ResolveField (_Jv_Field *, java::lang::ClassLoader*);
void _Jv_InitField (jobject, jclass, int);
void * _Jv_AllocMethodInvocation (jsize size);
/* FIXME: this should really be defined in some more generic place */
#define ROUND(V, A) (((((unsigned) (V))-1) | ((A)-1))+1)
/* the interpreter is written in C++, primarily because it makes it easy for
* the entire thing to be "friend" with class Class. */
class _Jv_InterpClass;
class _Jv_InterpMethod;
class _Jv_InterpMethodInvocation;
class _Jv_InterpException {
int start_pc;
int end_pc;
int handler_pc;
int handler_type;
friend class _Jv_ClassReader;
friend class _Jv_InterpMethod;
};
class _Jv_InterpMethod {
_Jv_ushort max_stack;
_Jv_ushort max_locals;
int code_length;
_Jv_ushort exc_count;
_Jv_ushort args_raw_size;
_Jv_InterpClass *defining_class;
_Jv_Method *self;
unsigned char* bytecode ()
{
return
((unsigned char*)this)
+ ROUND((sizeof (_Jv_InterpMethod)
+ exc_count*sizeof (_Jv_InterpException)), 4);
}
_Jv_InterpException * exceptions ()
{
return (_Jv_InterpException*) (this+1);
}
static size_t size (int exc_count, int code_length)
{
return
ROUND ((sizeof (_Jv_InterpMethod)
+ (exc_count * sizeof (_Jv_InterpException))), 4)
+ code_length;
}
// return the method's invocation pointer (a stub).
void *ncode ();
void continue1 (_Jv_InterpMethodInvocation *inv);
static void run_normal (ffi_cif*, void*, void**, void*);
static void run_synch_object (ffi_cif*, void*, void**, void*);
static void run_synch_class (ffi_cif*, void*, void**, void*);
inline jobject run (ffi_cif*, void*, void**,
_Jv_InterpMethodInvocation*);
bool find_exception (jobject ex,
_Jv_InterpMethodInvocation *inv);
public:
static void dump_object(jobject o);
friend class _Jv_ClassReader;
friend class _Jv_InterpMethodInvocation;
friend class gnu::gcj::runtime::MethodInvocation;
friend void _Jv_PrepareClass(jclass);
friend void _Jv_callInterpretedMethod (ffi_cif*,
void*,
void **,
void*);
};
class _Jv_InterpMethodInvocation {
_Jv_InterpMethod *running;
void **sp;
unsigned char *pc;
void* state[0];
void** stack_base () { return &state[0]; }
void** local_base () { return &state[running->max_stack]; }
friend class _Jv_InterpMethod;
};
class _Jv_InterpClass : public java::lang::Class
{
_Jv_InterpMethod **interpreted_methods;
_Jv_ushort *field_initializers;
friend class _Jv_ClassReader;
friend class _Jv_InterpMethod;
friend void _Jv_PrepareClass(jclass);
friend void _Jv_InitField (jobject, jclass, int);
friend void* _Jv_MarkObj (void *, void *, void *, void *);
};
struct _Jv_ResolvedMethod {
jint stack_item_count;
jint vtable_index;
jclass klass;
_Jv_Method* method;
// a resolved method holds the cif in-line, so that _Jv_MarkObj just needs
// to mark the resolved method to hold on to the cif. Some memory could be
// saved by keeping a cache of cif's, since many will be the same.
ffi_cif cif;
ffi_type * arg_types[0];
};
#endif /* INTERPRETER */
#endif /* __JAVA_INTERP_H__ */

View file

@ -162,6 +162,7 @@ extern "Java"
class VerifyError;
class VirtualMachineError;
class Void;
class VMClassLoader;
namespace reflect
{
class AccessibleObject;

View file

@ -40,6 +40,8 @@ extern int _Jv_strLengthUtf8(char* str, int len);
typedef struct _Jv_Utf8Const Utf8Const;
_Jv_Utf8Const *_Jv_makeUtf8Const (char *s, int len);
_Jv_Utf8Const *_Jv_makeUtf8TypeConst (char* s, int len);
_Jv_Utf8Const *_Jv_makeUtf8Const (jstring string);
extern jboolean _Jv_equalUtf8Consts (_Jv_Utf8Const *, _Jv_Utf8Const *);
extern jboolean _Jv_equal (_Jv_Utf8Const *, jstring, jint);
@ -91,6 +93,8 @@ extern "C" void *_Jv_LookupInterfaceMethod (jclass klass, Utf8Const *name,
extern "C" void _Jv_CheckArrayStore (jobject array, jobject obj);
extern "C" void _Jv_RegisterClass (jclass klass);
extern "C" void _Jv_RegisterClasses (jclass *classes);
extern void _Jv_UnregisterClass (_Jv_Utf8Const*, java::lang::ClassLoader*);
extern jclass _Jv_FindClass (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
extern jclass _Jv_FindClassFromSignature (char *,

2449
libjava/interpret.cc Normal file

File diff suppressed because it is too large Load diff

View file

@ -21,25 +21,30 @@ details. */
extern "C" void _Jv_InitClass (jclass klass);
extern "C" void _Jv_RegisterClasses (jclass *classes);
// These are the possible values for the `state' field of the class
// structure. Note that ordering is important here; in particular
// `resolved' must come between `nothing' and the other states.
// Whenever the state changes, one should notify all waiters of this
// class.
#define JV_STATE_NOTING 0 // set by compiler
#define JV_STATE_PRELOADING 1 // can do _Jv_FindClass
#define JV_STATE_LOADING 3 // has super installed
#define JV_STATE_LOADED 5 // is complete
#define JV_STATE_COMPILED 6 // this was a compiled class
#define JV_STATE_PREPARED 7 // layout & static init done
#define JV_STATE_LINKED 9 // strings interned
#define JV_STATE_IN_PROGRESS 10 // <clinit> running
#define JV_STATE_DONE 12 //
#define JV_STATE_ERROR 14 // must be last
struct _Jv_Field;
struct _Jv_VTable;
#define CONSTANT_Class 7
#define CONSTANT_Fieldref 9
#define CONSTANT_Methodref 10
#define CONSTANT_InterfaceMethodref 11
#define CONSTANT_String 8
#define CONSTANT_Integer 3
#define CONSTANT_Float 4
#define CONSTANT_Long 5
#define CONSTANT_Double 6
#define CONSTANT_NameAndType 12
#define CONSTANT_Utf8 1
#define CONSTANT_Unicode 2
#define CONSTANT_ResolvedFlag 16
#define CONSTANT_ResolvedString (CONSTANT_String+CONSTANT_ResolvedFlag)
#define CONSTANT_ResolvedClass (CONSTANT_Class+CONSTANT_ResolvedFlag)
struct _Jv_Constants
{
jint size;
@ -134,9 +139,11 @@ public:
return size_in_bytes;
}
// finalization
void finalize ();
private:
void checkMemberAccess (jint flags);
void resolveConstants (void);
// Various functions to handle class initialization.
java::lang::Throwable *hackTrampoline (jint, java::lang::Throwable *);
@ -147,12 +154,6 @@ private:
friend _Jv_Method *_Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature);
friend void _Jv_InitClass (jclass klass);
friend void _Jv_RegisterClasses (jclass *classes);
friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
friend jclass _Jv_FindArrayClass (jclass element);
friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader);
friend jfieldID JvGetFirstInstanceField (jclass);
friend jint JvNumInstanceFields (jclass);
@ -165,6 +166,41 @@ private:
friend class _Jv_PrimClass;
// Friends classes and functions to implement the ClassLoader
friend class java::lang::ClassLoader;
friend void _Jv_WaitForState (jclass, int);
friend void _Jv_RegisterClasses (jclass *classes);
friend void _Jv_RegisterInitiatingLoader (jclass,java::lang::ClassLoader*);
friend void _Jv_UnregisterClass (jclass);
friend jclass _Jv_FindClass (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
friend jclass _Jv_FindClassInCache (_Jv_Utf8Const *name,
java::lang::ClassLoader *loader);
friend jclass _Jv_FindArrayClass (jclass element,
java::lang::ClassLoader *loader);
friend jclass _Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader);
friend void _Jv_InternClassStrings (jclass);
#ifdef INTERPRETER
friend jboolean _Jv_IsInterpretedClass (jclass);
friend void _Jv_InitField (jobject, jclass, _Jv_Field*);
friend _Jv_Method* _Jv_LookupDeclaredMethod (jclass, _Jv_Utf8Const *,
_Jv_Utf8Const*);
friend int _Jv_DetermineVTableIndex (jclass, _Jv_Utf8Const *,
_Jv_Utf8Const*);
friend void _Jv_InitField (jobject, jclass, int);
friend void* _Jv_ResolvePoolEntry (jclass, int);
friend void _Jv_PrepareClass (jclass);
friend class _Jv_ClassReader;
friend class _Jv_InterpClass;
friend class _Jv_InterpMethod;
friend class _Jv_InterpMethodInvocation;
#endif
#ifdef JV_MARKOBJ_DECL
friend JV_MARKOBJ_DECL;
#endif

View file

@ -152,4 +152,7 @@ public final class Class implements Serializable
// Initialize the class.
private native void initializeClass ();
// finalization
protected native void finalize ();
}

View file

@ -9,86 +9,394 @@ Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
package java.lang;
import java.io.InputStream;
import java.util.Hashtable;
import java.net.URL;
import java.net.URLConnection;
import java.util.Stack;
/**
* @author Tom Tromey <tromey@cygnus.com>
* @date October 28, 1998
* The class <code>ClassLoader</code> is intended to be subclassed by
* applications in order to describe new ways of loading classes,
* such as over the network.
*
* @author Kresten Krab Thorup
*/
/* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
* Status: Just a stub; not useful at all.
*/
public abstract class ClassLoader
{
protected ClassLoader ()
{
cache = new Hashtable ();
public abstract class ClassLoader {
static private ClassLoader system;
private static native ClassLoader getVMClassLoader0 ();
static public ClassLoader getSystemClassLoader () {
if (system == null)
system = getVMClassLoader0 ();
return system;
}
protected final Class defineClass (String className, byte[] bytecode,
int offset, int length)
/**
* Creates a <code>ClassLoader</code>. The only thing this
* constructor does, is to call
* <code>checkCreateClassLoader</code> on the current
* security manager.
* @exception java.lang.SecurityException if not allowed
*/
protected ClassLoader()
{
throw new ClassFormatError ("defineClass unimplemented");
SecurityManager security = System.getSecurityManager ();
if (security != null)
security.checkCreateClassLoader ();
}
protected final Class defineClass (byte[] bytecodes,
int offset, int length)
{
return defineClass (null, bytecodes, offset, length);
}
protected final Class findLoadedClass (String className)
{
return (Class) cache.get(className);
}
protected final Class findSystemClass (String className)
throws ClassNotFoundException
{
Class c = system.findLoadedClass(className);
system.resolveClass(c);
return c;
}
// FIXME: Needs URL.
// public URL getResource (String resName);
public InputStream getResourceAsStream (String resName)
{
return null;
}
// FIXME: Needs URL.
// public static final URL getSystemResource (String resName);
public static final InputStream getSystemResourceAsStream (String resName)
{
return null;
}
protected abstract Class loadClass (String className, boolean resolve)
throws ClassNotFoundException;
public Class loadClass (String name) throws ClassNotFoundException
/**
* Loads and link the class by the given name.
* @param name the name of the class.
* @return the class loaded.
* @see ClassLoader#loadClass(String,boolean)
* @exception java.lang.ClassNotFoundException
*/
public Class loadClass(String name)
throws java.lang.ClassNotFoundException, java.lang.LinkageError
{
return loadClass (name, true);
}
protected final void resolveClass (Class c)
/**
* Loads the class by the given name.
* As per java 1.1, this has been deprecated. Use
* <code>loadClass(String)</code>
* instead.
* @param name the name of the class.
* @param link if the class should be linked.
* @return the class loaded.
* @exception java.lang.ClassNotFoundException
* @deprecated
*/
protected abstract Class loadClass(String name, boolean link)
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
/**
* Defines a class, given the class-data. According to the JVM, this
* method should not be used; instead use the variant of this method
* in which the name of the class being defined is specified
* explicitly.
* <P>
* If the name of the class, as specified (implicitly) in the class
* data, denotes a class which has already been loaded by this class
* loader, an instance of
* <code>java.lang.ClassNotFoundException</code> will be thrown.
*
* @param data bytes in class file format.
* @param off offset to start interpreting data.
* @param len length of data in class file.
* @return the class defined.
* @exception java.lang.ClassNotFoundException
* @exception java.lang.LinkageError
* @see ClassLoader#defineClass(String,byte[],int,int) */
protected final Class defineClass(byte[] data, int off, int len)
throws java.lang.ClassNotFoundException, java.lang.LinkageError
{
// Nothing for now.
return defineClass (null, data, off, len);
}
protected final void setSigners (Class cl, Object[] signers)
/**
* Defines a class, given the class-data. This is preferable
* over <code>defineClass(byte[],off,len)</code> since it is more
* secure. If the expected name does not match that of the class
* file, <code>ClassNotFoundException</code> is thrown. If
* <code>name</code> denotes the name of an already loaded class, a
* <code>LinkageError</code> is thrown.
* <p>
*
* FIXME: How do we assure that the class-file data is not being
* modified, simultaneously with the class loader running!? If this
* was done in some very clever way, it might break security.
* Right now I am thinking that defineclass should make sure never to
* read an element of this array more than once, and that that would
* assure the ``immutable'' appearance. It is still to be determined
* if this is in fact how defineClass operates.
*
* @param name the expected name.
* @param data bytes in class file format.
* @param off offset to start interpreting data.
* @param len length of data in class file.
* @return the class defined.
* @exception java.lang.ClassNotFoundException
* @exception java.lang.LinkageError
*/
protected final synchronized Class defineClass(String name,
byte[] data,
int off,
int len)
throws java.lang.ClassNotFoundException, java.lang.LinkageError
{
// Nothing for now.
if (data==null || data.length < off+len || off<0 || len<0)
throw new ClassFormatError ("arguments to defineClass "
+ "are meaningless");
// as per 5.3.5.1
if (name != null && findLoadedClass (name) != null)
throw new java.lang.LinkageError ("class "
+ name
+ " already loaded");
try {
// Since we're calling into native code here,
// we better make sure that any generated
// exception is to spec!
return defineClass0 (name, data, off, len);
} catch (java.lang.LinkageError x) {
throw x; // rethrow
} catch (java.lang.ClassNotFoundException x) {
throw x; // rethrow
} catch (java.lang.VirtualMachineError x) {
throw x; // rethrow
} catch (java.lang.Throwable x) {
// This should never happen, or we are beyond spec.
throw new InternalError ("Unexpected exception "
+ "while defining class "
+ name + ": "
+ x.toString ());
}
}
// Class cache.
private Hashtable cache;
/** This is the entry point of defineClass into the native code */
private native Class defineClass0 (String name,
byte[] data,
int off,
int len)
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
// The system class loader. FIXME: should have an actual value
private static final ClassLoader system = null;
/** This is called by defineClass0, once the "raw" and uninitialized
* class object has been created, and handles exceptions generated
* while actually defining the class (_Jv_DefineClass). defineClass0
* holds the lock on the new class object, so it needs to capture
* these exceptions. */
private static Throwable defineClass1 (Class klass, byte[] data,
int offset, int length)
{
try {
defineClass2 (klass, data, offset, length);
} catch (Throwable x) {
return x;
}
return null;
}
/** This is just a wrapper for _Jv_DefineClass */
private static native void defineClass2 (Class klass, byte[] data,
int offset, int length)
throws Throwable;
/**
* Link the given class. This will bring the class to a state where
* the class initializer can be run. Linking involves the following
* steps:
* <UL>
* <LI> Prepare (allocate and internalize) the constant strings that
* are used in this class.
* <LI> Allocate storage for static fields, and define the layout
* of instance fields.
* <LI> Perform static initialization of ``static final'' int,
* long, float, double and String fields for which there is a
* compile-time constant initializer.
* <LI> Create the internal representation of the ``vtable''.
* </UL>
* For <code>gcj</code>-compiled classes, only the first step is
* performed. The compiler will have done the rest already.
* <P>
* This is called by the system automatically,
* as part of class initialization; there is no reason to ever call
* this method directly.
* <P>
* For historical reasons, this method has a name which is easily
* misunderstood. Java classes are never ``resolved''. Classes are
* linked; whereas method and field references are resolved.
* <P>
* FIXME: The JDK documentation declares this method
* <code>final</code>, we declare it <code>static</code> -- any
* objections? This allows us to call it directly from native code
* with less hassle.
*
* @param clazz the class to link.
* @exception java.lang.LinkageError
*/
protected static void resolveClass(Class clazz)
throws java.lang.LinkageError
{
synchronized (clazz)
{
try {
linkClass0 (clazz);
} catch (Throwable x) {
markClassErrorState0 (clazz);
if (x instanceof Error)
throw (Error)x;
else
throw new java.lang.InternalError
("unexpected exception during linking: " + x);
}
}
}
/** Internal method. Calls _Jv_PrepareClass and
* _Jv_InternClassStrings. This is only called from resolveClass. */
private static native void linkClass0(Class clazz)
throws java.lang.LinkageError;
/** Internal method. Marks the given clazz to be in an erroneous
* state, and calls notifyAll() on the class object. This should only
* be called when the caller has the lock on the class object. */
private static native void markClassErrorState0(Class clazz);
/**
* Returns a class found in a system-specific way, typically
* via the <code>java.class.path</code> system property.
*
* @param name the class to resolve.
* @return the class loaded.
* @exception java.lang.LinkageError
* @exception java.lang.ClassNotFoundException
*/
protected native static Class findSystemClass(String name)
throws java.lang.ClassNotFoundException, java.lang.LinkageError;
/*
* Does currently nothing.
*/
protected final void setSigners(Class claz, Object[] signers) {
/* claz.setSigners (signers); */
}
/*
* If a class named <code>name</code> was previously loaded using
* this <code>ClassLoader</code>, then it is returned. Otherwise
* it returns <code>null</code>.
* @param name class to find.
* @return the class loaded, or null.
*/
protected native Class findLoadedClass(String name);
public static final InputStream getSystemResourceAsStream(String name) {
return system.getResourceAsStream (name);
}
public static final URL getSystemResource(String name) {
return system.getResource (name);
}
public static final byte[] getSystemResourceAsBytes(String name) {
return system.getResourceAsBytes (name);
}
/**
* Return an InputStream representing the resource name.
* This is essentially like
* <code>getResource(name).openStream()</code>, except
* it masks out any IOException and returns null on failure.
* @param name resource to load
* @return an InputStream, or null
* @see java.lang.ClassLoader#getResource(String)
* @see java.lang.ClassLoader#getResourceAsBytes(String)
* @see java.io.InputStream
*/
public InputStream getResourceAsStream(String name)
{
try {
URL res = getResource (name);
if (res == null) return null;
return res.openStream ();
} catch (java.io.IOException x) {
return null;
}
}
/**
* Return a byte array <code>byte[]</code> representing the
* resouce <code>name</code>. This only works for resources
* that have a known <code>content-length</code>, and
* it will block while loading the resource. Returns null
* for error conditions.<p>
* Since it is synchroneous, this is only convenient for
* resources that are "readily" available. System resources
* can conveniently be loaded this way, and the runtime
* system uses this to load class files. <p>
* To find the class data for a given class, use
* something like the following:
* <ul><code>
* String res = clazz.getName().replace ('.', '/')) + ".class";<br>
* byte[] data = getResourceAsBytes (res);
* </code></ul>
* @param name resource to load
* @return a byte array, or null
* @see java.lang.ClassLoader#getResource(String)
* @see java.lang.ClassLoader#getResourceAsStream(String)
*/
public byte[] getResourceAsBytes(String name) {
try {
URL res = getResource (name);
if (res == null) return null;
URLConnection conn = res.openConnection ();
int len = conn.getContentLength ();
if (len == -1) return null;
return readbytes (conn.getInputStream (), len);
} catch (java.io.IOException x) {
return null;
}
}
/**
* Return an java.io.URL representing the resouce <code>name</code>.
* @param name resource to load
* @return a URL, or null if there is no such resource.
* @see java.lang.ClassLoader#getResourceAsBytes(String)
* @see java.lang.ClassLoader#getResourceAsStream(String)
* @see java.io.URL
*/
public URL getResource(String name) {
return null;
}
/**
* Utility routine to read a resource fully, even if the given
* InputStream only provides partial results.
*/
private static byte[] readbytes (InputStream is, int length)
{
try {
byte[] data = new byte[length];
int read;
int off = 0;
while (off != length)
{
read = is.read (data, off, (int) (length-off));
if (read == -1)
return null;
off += read;
}
return data;
} catch (java.io.IOException x) {
return null;
}
}
}

View file

@ -19,12 +19,30 @@ package java.lang;
final class FirstThread extends Thread
{
public native void run ();
public native void run0 ();
public void run ()
{
try {
run0 ();
} catch (Throwable ex) {
System.err.println ("uncaught exception at top level");
ex.printStackTrace ();
}
}
public FirstThread (ThreadGroup g, Class k, Object o)
{
super (g, null, "main");
klass = k;
klass_name = null;
args = o;
}
public FirstThread (ThreadGroup g, String class_name, Object o)
{
super (g, null, "main");
klass = null;
klass_name = class_name;
args = o;
}
@ -36,5 +54,6 @@ final class FirstThread extends Thread
// Private data.
private Class klass;
private String klass_name;
private Object args;
}

View file

@ -0,0 +1,117 @@
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
package java.lang;
import java.io.*;
import java.net.URL;
import gnu.gcj.util.path.SearchPath;
final class VMClassLoader extends java.lang.ClassLoader
{
private SearchPath path;
private final String path_seperator;
private final String file_seperator;
private final char file_seperator_char;
private VMClassLoader () {
path_seperator = System.getProperty ("path.separator", ":");
file_seperator = System.getProperty ("file.separator", "/");
file_seperator_char = file_seperator.charAt (0);
String class_path = System.getProperty ("java.class.path", ".");
path = new SearchPath (class_path);
}
protected Class loadClass(String name,
boolean resolve)
throws java.lang.ClassNotFoundException, java.lang.LinkageError
{
return loadClassInternal (name, resolve, false);
}
/** I'm a little in doubt here, if this method is
actually supposed to throw a LinkageError, or not.
The spec, 20.14.3, is a little unclear. It says:
`` The general contract of loadClass is that, given the name
of a class, it either returns the Class object for the class
or throws a ClassNotFoundException.''
However, by making LinkageError a checked exception,
i.e., mention it directly in the throws clause,
we'll force caller to consider that case as well.
**/
protected Class loadClassInternal(String name,
boolean resolve,
boolean fromBootLoader)
throws java.lang.ClassNotFoundException, java.lang.LinkageError
{
Class clazz;
/** TODO: call _Jv_VerifyClassName **/
if ( (name.indexOf ('/') != -1)
|| (name.charAt (0) == '.')
|| (name.indexOf (file_seperator) != -1)
|| (name.indexOf ("..") != -1))
{
throw new IllegalArgumentException (name);
}
// already loaded?
clazz = findLoadedClass (name);
// we need access to the boot class loader here
if (clazz == null && !fromBootLoader)
clazz = findBootClass (name);
if (clazz == null)
{
StringBuffer res = new StringBuffer ();
// here we do actually replace .'s with /'s because
// we're going to find something in the file system.
res.append (name.replace ('.', file_seperator_char));
res.append (".class");
byte[] data = getResourceAsBytes (res.toString ());
if (data == null)
throw new ClassNotFoundException (name);
clazz = defineClass (name, data, 0, data.length);
}
if (resolve && clazz != null)
resolveClass (clazz);
return clazz;
}
private native Class findBootClass (String name);
public InputStream getResourceAsStream(String name)
{
return path.getStream (name);
}
public URL getResource(String name)
{
return path.getURL (name);
}
public byte[] getResourceAsBytes(String name)
{
return path.getBytes (name);
}
}

View file

@ -20,6 +20,11 @@ package java.lang;
* Status: Believed complete and correct.
*/
/* FIXME: We should consider adding some special error message when this
* exception is thrown, or maybe if it being caught at top-level. Such
* a message would direct the user to send a bug report to
* gcj-bugs@cygnus.com, or something like that. --KKT */
public abstract class VirtualMachineError extends Error
{
public VirtualMachineError ()

View file

@ -39,6 +39,8 @@ details. */
#include <java/lang/System.h>
#include <java/lang/SecurityManager.h>
#include <java-cpool.h>
#define CloneableClass _CL_Q34java4lang9Cloneable
@ -59,28 +61,6 @@ static _Jv_Utf8Const *void_signature = _Jv_makeUtf8Const ("()V", 3);
static _Jv_Utf8Const *clinit_name = _Jv_makeUtf8Const ("<clinit>", 8);
static _Jv_Utf8Const *init_name = _Jv_makeUtf8Const ("<init>", 6);
// These are the possible values for the `state' field. They more or
// less follow the section numbers in the Java Language Spec. Right
// now we don't bother to represent other interesting states, e.g. the
// states a class might inhabit before it is prepared. Note that
// ordering is important here; in particular `resolved' must come
// between `nothing' and the other states.
#define STATE_NOTHING 0
#define STATE_RESOLVED 1
#define STATE_IN_PROGRESS 6
#define STATE_DONE 9
#define STATE_ERROR 10
// Size of local hash table.
#define HASH_LEN 256
// Hash function for Utf8Consts.
#define HASH_UTF(Utf) (((Utf)->hash) % HASH_LEN)
// This is the table we use to keep track of loaded classes. See Spec
// section 12.2.
static jclass loaded_classes[HASH_LEN];
jclass
@ -111,6 +91,9 @@ java::lang::Class::forName (jstring className)
#endif
if (! klass)
JvThrow (new java::lang::ClassNotFoundException (className));
_Jv_InitClass (klass);
return klass;
}
@ -380,33 +363,13 @@ java::lang::Class::newInstance (void)
return r;
}
// Initialize the constants.
void
java::lang::Class::resolveConstants (void)
java::lang::Class::finalize (void)
{
for (int i = 0; i < constants.size; ++i)
{
if (constants.tags[i] == CONSTANT_String)
{
jstring str;
str = _Jv_NewStringUtf8Const ((_Jv_Utf8Const *) constants.data[i]);
constants.data[i] = (void *) str;
constants.tags[i] = CONSTANT_ResolvedString;
}
else if (constants.tags[i] == CONSTANT_Class)
{
_Jv_Utf8Const *name = (_Jv_Utf8Const *) constants.data[i];
jclass klass = _Jv_FindClassFromSignature (name->data, loader);
if (! klass)
{
jstring str = _Jv_NewStringUtf8Const (name);
JvThrow (new java::lang::ClassNotFoundException (str));
}
constants.data[i] = (void *) klass;
constants.tags[i] = CONSTANT_ResolvedClass;
}
}
#ifdef INTERPRETER
JvAssert (_Jv_IsInterpretedClass (this));
_Jv_UnregisterClass (this);
#endif
}
// FIXME.
@ -424,38 +387,52 @@ void
java::lang::Class::initializeClass (void)
{
// Short-circuit to avoid needless locking.
if (state == STATE_DONE)
if (state == JV_STATE_DONE)
return;
// do this before we enter the monitor below, since this can cause
// exceptions. Here we assume, that reading "state" is an atomic
// operation, I pressume that is true? --Kresten
if (state < JV_STATE_LINKED)
{
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (this))
{
java::lang::ClassLoader::resolveClass (this);
// Step 1.
_Jv_MonitorEnter (this);
// FIXME: This should actually be handled by calling into the class
// loader. For now we put it here.
if (state < STATE_RESOLVED)
}
else
#endif
{
// We set the state before calling resolveConstants to avoid
// infinite recursion when processing String or Class.
state = STATE_RESOLVED;
resolveConstants ();
// Step 1.
_Jv_MonitorEnter (this);
_Jv_InternClassStrings (this);
}
}
else
{
// Step 1.
_Jv_MonitorEnter (this);
}
// Step 2.
java::lang::Thread *self = java::lang::Thread::currentThread();
// FIXME: `self' can be null at startup. Hence this nasty trick.
self = (java::lang::Thread *) ((long) self | 1);
while (state == STATE_IN_PROGRESS && thread && thread != self)
while (state == JV_STATE_IN_PROGRESS && thread && thread != self)
wait ();
// Steps 3 & 4.
if (state == STATE_DONE || state == STATE_IN_PROGRESS || thread == self)
if (state == JV_STATE_DONE || state == JV_STATE_IN_PROGRESS || thread == self)
{
_Jv_MonitorExit (this);
return;
}
// Step 5.
if (state == STATE_ERROR)
if (state == JV_STATE_ERROR)
{
_Jv_MonitorExit (this);
JvThrow (new java::lang::NoClassDefFoundError);
@ -463,7 +440,7 @@ java::lang::Class::initializeClass (void)
// Step 6.
thread = self;
state = STATE_IN_PROGRESS;
state = JV_STATE_IN_PROGRESS;
_Jv_MonitorExit (this);
// Step 7.
@ -477,7 +454,7 @@ java::lang::Class::initializeClass (void)
{
// Caught an exception.
_Jv_MonitorEnter (this);
state = STATE_ERROR;
state = JV_STATE_ERROR;
notify ();
_Jv_MonitorExit (this);
JvThrow (except);
@ -492,7 +469,7 @@ java::lang::Class::initializeClass (void)
if (! except)
{
_Jv_MonitorEnter (this);
state = STATE_DONE;
state = JV_STATE_DONE;
}
else
{
@ -503,7 +480,7 @@ java::lang::Class::initializeClass (void)
except = hackTrampoline(2, except);
}
_Jv_MonitorEnter (this);
state = STATE_ERROR;
state = JV_STATE_ERROR;
}
notify ();
_Jv_MonitorExit (this);
@ -530,6 +507,64 @@ _Jv_GetMethodLocal (jclass klass, _Jv_Utf8Const *name,
return NULL;
}
#define MCACHE_SIZE 1013
struct _Jv_mcache {
jclass klass;
_Jv_Method *method;
};
static _Jv_mcache method_cache[MCACHE_SIZE];
static int method_cache_count;
static void*
_Jv_FindMethodInCache (jclass klass,
_Jv_Utf8Const *name,
_Jv_Utf8Const *signature)
{
for (int index = name->hash % MCACHE_SIZE;
method_cache[index].klass != NULL;
index = (index+1) % MCACHE_SIZE)
{
_Jv_mcache *mc = (method_cache+index);
_Jv_Method *m = mc->method;
if (mc->klass == klass
&& m != NULL // thread safe check
&& _Jv_equalUtf8Consts (m->name, name)
&& _Jv_equalUtf8Consts (m->signature, signature))
{
return mc->method->ncode;
}
}
return NULL;
}
static void
_Jv_AddMethodToCache (jclass klass,
_Jv_Method *method)
{
_Jv_MonitorEnter (&ClassClass);
if (method_cache_count > MCACHE_SIZE*2/3)
{
for (int i = 0; i < MCACHE_SIZE; i++)
method_cache[i].klass = 0;
}
for (int index = method->name->hash % MCACHE_SIZE;
method_cache[index].klass != NULL;
index = (index+1) % MCACHE_SIZE)
{
method_cache[index].method = method;
method_cache[index].klass = klass;
}
method_cache_count += 1;
_Jv_MonitorExit (&ClassClass);
}
void *
_Jv_LookupInterfaceMethod (jclass klass, _Jv_Utf8Const *name,
_Jv_Utf8Const *signature)
@ -539,6 +574,14 @@ _Jv_LookupInterfaceMethod (jclass klass, _Jv_Utf8Const *name,
// call a method of a class until the class is linked. But this
// captures the general idea.
// klass->getClassLoader()->resolveClass(klass);
//
// KKT: This is unnessecary, exactly for the reason you present:
// _Jv_LookupInterfaceMethod is only called on object instances, and
// such have already been initialized (which includes resolving).
void *ncode = _Jv_FindMethodInCache (klass, name, signature);
if (ncode != 0)
return ncode;
for (; klass; klass = klass->getSuperclass())
{
@ -553,6 +596,8 @@ _Jv_LookupInterfaceMethod (jclass klass, _Jv_Utf8Const *name,
if (! java::lang::reflect::Modifier::isPublic(meth->accflags))
JvThrow (new java::lang::IllegalAccessError);
_Jv_AddMethodToCache (klass, meth);
return meth->ncode;
}
JvThrow (new java::lang::IncompatibleClassChangeError);
@ -565,219 +610,6 @@ _Jv_InitClass (jclass klass)
klass->initializeClass();
}
// This function is called many times during startup, before main() is
// run. We do our runtime initialization here the very first time we
// are called. At that point in time we know for certain we are
// running single-threaded, so we don't need to lock when modifying
// `init'. CLASSES is NULL-terminated.
void
_Jv_RegisterClasses (jclass *classes)
{
static bool init = false;
if (! init)
{
init = true;
_Jv_InitThreads ();
_Jv_InitGC ();
_Jv_InitializeSyncMutex ();
}
JvSynchronize sync (&ClassClass);
for (; *classes; ++classes)
{
jclass klass = *classes;
jint hash = HASH_UTF (klass->name);
klass->next = loaded_classes[hash];
loaded_classes[hash] = klass;
}
}
void
_Jv_RegisterClass (jclass klass)
{
jclass classes[2];
classes[0] = klass;
classes[1] = NULL;
_Jv_RegisterClasses (classes);
}
jclass
_Jv_FindClassInCache (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
{
JvSynchronize sync (&ClassClass);
jint hash = HASH_UTF (name);
jclass klass;
for (klass = loaded_classes[hash]; klass; klass = klass->next)
{
if (loader == klass->loader && _Jv_equalUtf8Consts (name, klass->name))
break;
}
return klass;
}
#if 0
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_equalUtf8Consts (klass->name, name, hash))
break;
}
return klass;
}
#endif
jclass
_Jv_FindClass (_Jv_Utf8Const* name, java::lang::ClassLoader *loader)
{
jclass klass = _Jv_FindClassInCache (name, loader);
if (loader && ! klass)
{
klass = loader->loadClass(_Jv_NewStringUtf8Const (name));
if (klass)
_Jv_RegisterClass (klass);
}
return klass;
}
#if 0
jclass
_Jv_FindClass (jstring name, java::lang::ClassLoader *loader)
{
jclass klass = _Jv_FindClassInCache (name, loader);
if (loader && ! klass)
{
klass = loader->loadClass(name);
if (klass)
_Jv_RegisterClass (klass);
}
return klass;
}
#endif
jclass
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader)
{
jclass ret = (jclass) JvAllocObject (&ClassClass);
ret->next = NULL;
ret->name = name;
ret->accflags = 0;
ret->superclass = superclass;
ret->constants.size = 0;
ret->constants.tags = NULL;
ret->constants.data = NULL;
ret->methods = NULL;
ret->method_count = 0;
ret->vtable_method_count = 0;
ret->fields = NULL;
ret->size_in_bytes = 0;
ret->field_count = 0;
ret->static_field_count = 0;
ret->vtable = NULL;
ret->interfaces = NULL;
ret->loader = loader;
ret->interface_count = 0;
ret->state = 0;
ret->thread = NULL;
_Jv_RegisterClass (ret);
return ret;
}
jclass
_Jv_FindArrayClass (jclass element)
{
_Jv_Utf8Const *array_name;
int len;
if (element->isPrimitive())
{
// For primitive types the array is cached in the class.
jclass ret = (jclass) element->methods;
if (ret)
return ret;
len = 3;
}
else
len = element->name->length + 5;
{
char signature[len];
int index = 0;
signature[index++] = '[';
// Compute name of array class to see if we've already cached it.
if (element->isPrimitive())
{
signature[index++] = (char) element->method_count;
}
else
{
size_t length = element->name->length;
const char *const name = element->name->data;
if (name[0] != '[')
signature[index++] = 'L';
memcpy (&signature[index], name, length);
index += length;
if (name[0] != '[')
signature[index++] = ';';
}
array_name = _Jv_makeUtf8Const (signature, index);
}
jclass array_class = _Jv_FindClassInCache (array_name, element->loader);
if (! array_class)
{
// Create new array class.
array_class = _Jv_NewClass (array_name, &ObjectClass, element->loader);
// Note that `vtable_method_count' doesn't include the initial
// NULL slot.
int dm_count = ObjectClass.vtable_method_count + 1;
// Create a new vtable by copying Object's vtable (except the
// class pointer, of course). Note that we allocate this as
// unscanned memory -- the vtables are handled specially by the
// GC.
int size = (sizeof (_Jv_VTable) +
((dm_count - 1) * sizeof (void *)));
_Jv_VTable *vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
vtable->clas = array_class;
memcpy (vtable->method, ObjectClass.vtable->method,
dm_count * sizeof (void *));
array_class->vtable = vtable;
array_class->vtable_method_count = ObjectClass.vtable_method_count;
// Stash the pointer to the element type.
array_class->methods = (_Jv_Method *) element;
// Register our interfaces.
// FIXME: for JDK 1.2 we need Serializable.
static jclass interfaces[] = { &CloneableClass };
array_class->interfaces = interfaces;
array_class->interface_count = 1;
// FIXME: initialize other Class instance variables,
// e.g. `fields'.
array_class->state = STATE_DONE;
}
// For primitive types, point back at this array.
if (element->isPrimitive())
element->methods = (_Jv_Method *) array_class;
return array_class;
}
jboolean
_Jv_IsInstanceOf(jobject obj, jclass cl)
{

View file

@ -0,0 +1,624 @@
// natClassLoader.cc - Implementation of java.lang.ClassLoader native methods.
/* Copyright (C) 1999 Cygnus Solutions
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
/* Author: Kresten Krab Thorup <krab@gnu.org> */
#include <config.h>
#include <stdlib.h>
#include <string.h>
#include <cni.h>
#include <jvm.h>
#include <java/lang/Character.h>
#include <java/lang/Thread.h>
#include <java/lang/ClassLoader.h>
#include <java/lang/VMClassLoader.h>
#include <java/lang/InternalError.h>
#include <java/lang/LinkageError.h>
#include <java/lang/ClassFormatError.h>
#include <java/lang/NoClassDefFoundError.h>
#include <java/lang/ClassNotFoundException.h>
#include <java/lang/ClassCircularityError.h>
#include <java/lang/IncompatibleClassChangeError.h>
#include <java/lang/reflect/Modifier.h>
#include <java-interp.h>
#define CloneableClass _CL_Q34java4lang9Cloneable
extern java::lang::Class CloneableClass;
#define ObjectClass _CL_Q34java4lang6Object
extern java::lang::Class ObjectClass;
#define ClassClass _CL_Q34java4lang5Class
extern java::lang::Class ClassClass;
#define VMClassLoaderClass _CL_Q34java4lang17VMClassLoader
extern java::lang::Class VMClassLoader;
#define ClassLoaderClass _CL_Q34java4lang11ClassLoader
extern java::lang::Class ClassLoaderClass;
/////////// java.lang.ClassLoader native methods ////////////
#ifdef INTERPRETER
java::lang::VMClassLoader *redirect = 0;
#endif
java::lang::ClassLoader*
java::lang::ClassLoader::getVMClassLoader0 ()
{
#ifdef INTERPRETER
if (redirect == 0)
redirect = new java::lang::VMClassLoader;
return redirect;
#else
return 0;
#endif
}
void
java::lang::ClassLoader::defineClass2 (jclass klass, jbyteArray data,
jint offset, jint length)
{
#ifdef INTERPRETER
_Jv_DefineClass (klass, data, offset, length);
#endif
}
java::lang::Class *
java::lang::ClassLoader::defineClass0 (jstring name,
jbyteArray data,
jint offset,
jint length)
{
#ifdef INTERPRETER
jclass klass;
klass = (jclass) JvAllocObject (&ClassClass, sizeof (_Jv_InterpClass));
// synchronize on the class, so that it is not
// attempted initialized until we're done loading.
_Jv_MonitorEnter (klass);
// record which is the defining loader
klass->loader = this;
// register that we are the initiating loader...
if (name != 0)
{
_Jv_Utf8Const * name2 = _Jv_makeUtf8Const (name);
_Jv_VerifyClassName (name2);
klass->name = name2;
}
// this will do the magic. loadInto also operates
// as an exception trampoline for now...
Throwable *ex = defineClass1 (klass, data, offset, length);
if (ex) // we failed to load it
{
klass->state = JV_STATE_ERROR;
klass->notifyAll ();
_Jv_UnregisterClass (klass);
_Jv_MonitorExit (klass);
// FIXME: Here we may want to test that EX does
// indeed represent a valid exception. That is,
// anything but ClassNotFoundException,
// or some kind of Error.
JvThrow (ex);
}
// if everything proceeded sucessfully, we're loaded.
JvAssert (klass->state == JV_STATE_LOADED);
// if an exception is generated, this is initially missed.
// however, we come back here in handleException0 below...
_Jv_MonitorExit (klass);
return klass;
#else // INTERPRETER
return 0;
#endif
}
void
_Jv_WaitForState (jclass klass, int state)
{
if (klass->state >= state)
return;
_Jv_MonitorEnter (klass) ;
if (state == JV_STATE_LINKED)
{
_Jv_MonitorExit (klass);
_Jv_InternClassStrings (klass);
return;
}
java::lang::Thread *self = java::lang::Thread::currentThread();
// this is similar to the strategy for class initialization.
// if we already hold the lock, just leave.
while (klass->state <= state
&& klass->thread
&& klass->thread != self)
klass->wait ();
_Jv_MonitorExit (klass);
if (klass->state == JV_STATE_ERROR)
{
_Jv_Throw (new java::lang::LinkageError ());
}
}
// Finish linking a class. Only called from ClassLoader::resolveClass.
void
java::lang::ClassLoader::linkClass0 (java::lang::Class *klass)
{
if (klass->state >= JV_STATE_LINKED)
return;
#ifdef INTERPRETER
if (_Jv_IsInterpretedClass (klass))
{
_Jv_PrepareClass (klass);
}
#endif
_Jv_InternClassStrings (klass);
}
void
java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
{
klass->state = JV_STATE_ERROR;
klass->notifyAll ();
}
/** this is the only native method in VMClassLoader, so
we define it here. */
jclass
java::lang::VMClassLoader::findBootClass (jstring name)
{
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), 0);
}
jclass
java::lang::ClassLoader::findLoadedClass (jstring name)
{
return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), this);
}
jclass
java::lang::ClassLoader::findSystemClass (jstring name)
{
return _Jv_FindClass (_Jv_makeUtf8Const (name), 0);
}
/* This is the final step of linking, internalizing the constant strings
* of a class. This is called for both compiled and interpreted
* classes, and it is *only* called from ClassLoader::linkClass0,
* which is always in a context where the current thread has a lock on
* the class in question. We define it here, and not in resolve.cc, so that
* the entire resolve.cc can be #ifdef'ed away when not using the
* interpreter. */
void
_Jv_InternClassStrings(jclass klass)
{
if (klass->state >= JV_STATE_LINKED)
return;
// short-circuit, so that mutually dependent classes are ok
klass->state = JV_STATE_LINKED;
_Jv_Constants *pool = &klass->constants;
for (int i = 1; i < pool->size; ++i)
{
if (pool->tags[i] == JV_CONSTANT_String)
{
jstring str;
str = _Jv_NewStringUtf8Const ((_Jv_Utf8Const *) pool->data[i]);
pool->data[i] = (void *) str;
pool->tags[i] |= JV_CONSTANT_ResolvedFlag;
}
}
klass->notifyAll ();
}
//
// A single class can have many "initiating" class loaders,
// and a single "defining" class loader. The Defining
// class loader is what is returned from Class.getClassLoader()
// and is used when loading dependent classes during resolution.
// The set of initiating class loaders are used to ensure
// safety of linking, and is maintained in the hash table
// "initiated_classes". A defining classloader is by definition also
// initiating, so we only store classes in this table, if they have more
// than one class loader associated.
//
// Size of local hash table.
#define HASH_LEN 1013
// Hash function for Utf8Consts.
#define HASH_UTF(Utf) (((Utf)->hash) % HASH_LEN)
struct _Jv_LoaderInfo {
_Jv_LoaderInfo *next;
java::lang::Class *klass;
java::lang::ClassLoader *loader;
};
_Jv_LoaderInfo *initiated_classes[HASH_LEN];
jclass loaded_classes[HASH_LEN];
jclass
_Jv_FindClassInCache (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
{
_Jv_MonitorEnter (&ClassClass);
jint hash = HASH_UTF (name);
// first, if LOADER is a defining loader, then it is also initiating
jclass klass;
for (klass = loaded_classes[hash]; klass; klass = klass->next)
{
if (loader == klass->loader && _Jv_equalUtf8Consts (name, klass->name))
break;
}
// otherwise, it may be that the class in question was defined
// by some other loader, but that the loading was initiated by
// the loader in question.
if (!klass)
{
_Jv_LoaderInfo *info;
for (info = initiated_classes[hash]; info; info = info->next)
{
if (loader == info->loader
&& _Jv_equalUtf8Consts (name, info->klass->name))
{
klass = info->klass;
break;
}
}
}
_Jv_MonitorExit (&ClassClass);
return klass;
}
void
_Jv_UnregisterClass (jclass the_class)
{
_Jv_MonitorEnter (&ClassClass);
jint hash = HASH_UTF(the_class->name);
jclass *klass = &(loaded_classes[hash]);
for ( ; *klass; klass = &((*klass)->next))
{
if (*klass == the_class)
{
*klass = (*klass)->next;
break;
}
}
_Jv_LoaderInfo **info = &(initiated_classes[hash]);
for ( ; *info; info = &((*info)->next))
{
while ((*info)->klass == the_class)
{
*info = (*info)->next;
}
}
_Jv_MonitorExit (&ClassClass);
}
void
_Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
{
_Jv_LoaderInfo *info = new _Jv_LoaderInfo; // non-gc alloc!
jint hash = HASH_UTF(klass->name);
_Jv_MonitorEnter (&ClassClass);
info->loader = loader;
info->klass = klass;
info->next = initiated_classes[hash];
initiated_classes[hash] = info;
_Jv_MonitorExit (&ClassClass);
}
// This function is called many times during startup, before main() is
// run. We do our runtime initialization here the very first time we
// are called. At that point in time we know for certain we are
// running single-threaded, so we don't need to lock when modifying
// `init'. CLASSES is NULL-terminated.
void
_Jv_RegisterClasses (jclass *classes)
{
static bool init = false;
if (! init)
{
init = true;
_Jv_InitThreads ();
_Jv_InitGC ();
_Jv_InitializeSyncMutex ();
}
JvSynchronize sync (&ClassClass);
for (; *classes; ++classes)
{
jclass klass = *classes;
jint hash = HASH_UTF (klass->name);
klass->next = loaded_classes[hash];
loaded_classes[hash] = klass;
// registering a compiled class causes
// it to be immediately "prepared".
if (klass->state == JV_STATE_NOTING)
klass->state = JV_STATE_COMPILED;
}
}
void
_Jv_RegisterClass (jclass klass)
{
jclass classes[2];
classes[0] = klass;
classes[1] = NULL;
_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)
{
jclass klass = _Jv_FindClassInCache (name, loader);
#ifdef INTERPRETER
if (! klass)
{
jstring sname = _Jv_NewStringUTF (name->data);
if (loader)
{
// Load using a user-defined loader, jvmspec 5.3.2
klass = loader->loadClass(sname, false);
// if "loader" delegateted the loadClass operation
// to another loader, register explicitly
// that he is also an initiating loader of the
// given class.
if (klass && (klass->getClassLoader () != loader))
_Jv_RegisterInitiatingLoader (klass, 0);
}
else
{
if (redirect == NULL)
{
_Jv_InitClass (&ClassLoaderClass);
java::lang::ClassLoader::getSystemClassLoader ();
}
// Load using the bootstrap loader jmspec 5.3.1
klass = redirect -> loadClassInternal (sname, false, true);
// register that we're an initiating loader
if (klass)
{
_Jv_RegisterInitiatingLoader (klass, 0);
}
}
}
else
{
// we need classes to be in the hash while
// 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,
java::lang::ClassLoader *loader)
{
jclass ret = (jclass) JvAllocObject (&ClassClass);
ret->next = NULL;
ret->name = name;
ret->accflags = 0;
ret->superclass = superclass;
ret->constants.size = 0;
ret->constants.tags = NULL;
ret->constants.data = NULL;
ret->methods = NULL;
ret->method_count = 0;
ret->vtable_method_count = 0;
ret->fields = NULL;
ret->size_in_bytes = 0;
ret->field_count = 0;
ret->static_field_count = 0;
ret->vtable = NULL;
ret->interfaces = NULL;
ret->loader = loader;
ret->interface_count = 0;
ret->state = 0;
ret->thread = NULL;
_Jv_RegisterClass (ret);
return ret;
}
jclass
_Jv_FindArrayClass (jclass element, java::lang::ClassLoader *loader)
{
_Jv_Utf8Const *array_name;
int len;
if (element->isPrimitive())
{
// For primitive types the array is cached in the class.
jclass ret = (jclass) element->methods;
if (ret)
return ret;
len = 3;
}
else
len = element->name->length + 5;
{
char signature[len];
int index = 0;
signature[index++] = '[';
// Compute name of array class to see if we've already cached it.
if (element->isPrimitive())
{
signature[index++] = (char) element->method_count;
}
else
{
size_t length = element->name->length;
const char *const name = element->name->data;
if (name[0] != '[')
signature[index++] = 'L';
memcpy (&signature[index], name, length);
index += length;
if (name[0] != '[')
signature[index++] = ';';
}
array_name = _Jv_makeUtf8Const (signature, index);
}
jclass array_class = _Jv_FindClassInCache (array_name, element->loader);
if (! array_class)
{
// Create new array class.
array_class = _Jv_NewClass (array_name, &ObjectClass, element->loader);
// Note that `vtable_method_count' doesn't include the initial
// NULL slot.
int dm_count = ObjectClass.vtable_method_count + 1;
// Create a new vtable by copying Object's vtable (except the
// class pointer, of course). Note that we allocate this as
// unscanned memory -- the vtables are handled specially by the
// GC.
int size = (sizeof (_Jv_VTable) +
((dm_count - 1) * sizeof (void *)));
_Jv_VTable *vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
vtable->clas = array_class;
memcpy (vtable->method, ObjectClass.vtable->method,
dm_count * sizeof (void *));
array_class->vtable = vtable;
array_class->vtable_method_count = ObjectClass.vtable_method_count;
// Stash the pointer to the element type.
array_class->methods = (_Jv_Method *) element;
// Register our interfaces.
// FIXME: for JDK 1.2 we need Serializable.
static jclass interfaces[] = { &CloneableClass };
array_class->interfaces = interfaces;
array_class->interface_count = 1;
// as per vmspec 5.3.3.2
array_class->accflags = element->accflags;
// FIXME: initialize other Class instance variables,
// e.g. `fields'.
// say this class is initialized and ready to go!
array_class->state = JV_STATE_DONE;
// vmspec, section 5.3.3 describes this
if (element->loader != loader)
_Jv_RegisterInitiatingLoader (array_class, loader);
}
// For primitive types, point back at this array.
if (element->isPrimitive())
element->methods = (_Jv_Method *) array_class;
return array_class;
}

View file

@ -27,7 +27,7 @@ details. */
typedef void main_func (jobject);
void
java::lang::FirstThread::run (void)
java::lang::FirstThread::run0 (void)
{
Utf8Const* main_signature = _Jv_makeUtf8Const ("([Ljava.lang.String;)V", 22);
Utf8Const* main_name = _Jv_makeUtf8Const ("main", 4);
@ -41,6 +41,12 @@ java::lang::FirstThread::run (void)
DIE ("class must be public");
#endif
if (klass == NULL)
{
klass = java::lang::Class::forName (klass_name);
if (klass != NULL) _Jv_InitClass (klass);
}
_Jv_Method *meth = _Jv_GetMethodLocal (klass, main_name, main_signature);
// Some checks from Java Spec section 12.1.4.

View file

@ -45,10 +45,11 @@ java::lang::reflect::Array::newInstance (jclass componentType, jintArray dimensi
if (ndims == 1)
return newInstance (componentType, dims[0]);
jclass arrayType = componentType;
for (int i = 0; i < ndims; i++)
arrayType = _Jv_FindArrayClass (arrayType);
return _Jv_NewMultiArray (arrayType, ndims, dims);
for (int i = 0; i < ndims; i++) // FIXME 2nd arg should
// be "current" loader
arrayType = _Jv_FindArrayClass (arrayType, 0);
return _Jv_NewMultiArray (arrayType, ndims, dims);
}
jint

View file

@ -378,8 +378,10 @@ java::lang::reflect::Method::getType ()
while (*ptr != ';' && ptr[1] != '\0');
break;
}
// FIXME: 2'nd argument should be "current loader"
while (--num_arrays >= 0)
type = _Jv_FindArrayClass (type);
type = _Jv_FindArrayClass (type, 0);
*argPtr++ = type;
}
parameter_types = args;

View file

@ -354,7 +354,7 @@ java::net::PlainSocketImpl::getOption (jint optID)
if (l_val.l_onoff)
return new java::lang::Integer (l_val.l_linger);
else
return new java::lang::Boolean (false);
return new java::lang::Boolean ((__java_boolean)false);
#else
JvThrow (new java::lang::InternalError (
JvNewStringUTF ("SO_LINGER not supported")));

View file

@ -4,7 +4,7 @@
# to link with libgcj.
#
%rename lib liborig
*lib: -lgcj -lm @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig)
*lib: -lgcj -lm @INTERPSPEC@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(liborig)
%rename cc1 cc1orig
*cc1: @DIVIDESPEC@ %(cc1orig)

View file

@ -180,6 +180,24 @@ _Jv_makeUtf8Const (char* s, int len)
return (m);
}
_Jv_Utf8Const *
_Jv_makeUtf8Const (jstring string)
{
jint hash = string->hashCode ();
jint len = _Jv_GetStringUTFLength (string);
Utf8Const* m = (Utf8Const*)
_Jv_AllocBytesChecked (sizeof(Utf8Const) + len + 1);
m->hash = hash;
m->length = len;
_Jv_GetStringUTFRegion (string, 0, string->length (), m->data);
m->data[len] = 0;
return m;
}
#ifdef DEBUG
@ -298,7 +316,10 @@ _Jv_NewObjectArray (jsize count, jclass elementClass, jobject init)
JvThrow (no_memory);
size_t size = count * sizeof (jobject) + sizeof (__JArray);
jclass clas = _Jv_FindArrayClass (elementClass);
// FIXME: second argument should be "current loader" //
jclass clas = _Jv_FindArrayClass (elementClass, 0);
jobjectArray obj = (jobjectArray) _Jv_AllocArray (size);
if (! obj)
JvThrow (no_memory);
@ -338,7 +359,7 @@ _Jv_NewPrimArray (jclass eltype, jint count)
arr->length = count;
// Note that we assume we are given zeroed memory by the allocator.
jclass klass = _Jv_FindArrayClass (eltype);
jclass klass = _Jv_FindArrayClass (eltype, 0);
// Set the vtbl last to avoid problems if the GC happens during the
// window in this function between the allocation and this
// assignment.
@ -531,9 +552,11 @@ _Jv_FindClassFromSignature (char *sig, java::lang::ClassLoader *loader)
;
_Jv_Utf8Const *name = _Jv_makeUtf8Const (&sig[1], i - 1);
return _Jv_FindClass (name, loader);
}
case '[':
return _Jv_FindArrayClass (_Jv_FindClassFromSignature (&sig[1], loader));
return _Jv_FindArrayClass (_Jv_FindClassFromSignature (&sig[1], loader),
loader);
}
JvFail ("couldn't understand class signature");
return NULL; // Placate compiler.
@ -588,9 +611,20 @@ JvRunMain (jclass klass, int argc, const char **argv)
LTDL_SET_PRELOADED_SYMBOLS ();
#endif
if (klass == NULL)
{
arg_vec = JvConvertArgv (argc - 2, argv + 2);
main_group = new java::lang::ThreadGroup (23);
main_thread = new java::lang::FirstThread (main_group,
JvNewStringLatin1 (argv[1]),
arg_vec);
}
else
{
arg_vec = JvConvertArgv (argc - 1, argv + 1);
main_group = new java::lang::ThreadGroup (23);
main_thread = new java::lang::FirstThread (main_group, klass, arg_vec);
}
main_thread->start();
_Jv_ThreadWait ();
@ -598,6 +632,7 @@ JvRunMain (jclass klass, int argc, const char **argv)
java::lang::Runtime::getRuntime ()->exit (0);
}
void *
@ -630,7 +665,7 @@ _Jv_divI (jint dividend, jint divisor)
if (divisor == 0)
_Jv_Throw (arithexception);
if (dividend == 0x80000000L && divisor == -1)
if (dividend == (jint) 0x80000000L && divisor == -1)
return dividend;
return dividend / divisor;
@ -642,7 +677,7 @@ _Jv_remI (jint dividend, jint divisor)
if (divisor == 0)
_Jv_Throw (arithexception);
if (dividend == 0x80000000L && divisor == -1)
if (dividend == (jint) 0x80000000L && divisor == -1)
return 0;
return dividend % divisor;
@ -654,7 +689,7 @@ _Jv_divJ (jlong dividend, jlong divisor)
if (divisor == 0)
_Jv_Throw (arithexception);
if (dividend == 0x8000000000000000LL && divisor == -1)
if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
return dividend;
return dividend / divisor;
@ -666,9 +701,15 @@ _Jv_remJ (jlong dividend, jlong divisor)
if (divisor == 0)
_Jv_Throw (arithexception);
if (dividend == 0x8000000000000000LL && divisor == -1)
if (dividend == (jlong) 0x8000000000000000LL && divisor == -1)
return 0;
return dividend % divisor;
}

1101
libjava/resolve.cc Normal file

File diff suppressed because it is too large Load diff

View file

@ -71,6 +71,7 @@ COMPPATH = @COMPPATH@
CPP = @CPP@
CXX = @CXX@
CXXCPP = @CXXCPP@
DIVIDESPEC = @DIVIDESPEC@
DLLTOOL = @DLLTOOL@
EH_COMMON_INCLUDE = @EH_COMMON_INCLUDE@
EXEEXT = @EXEEXT@
@ -79,6 +80,7 @@ GCINCS = @GCINCS@
GCLIBS = @GCLIBS@
GCOBJS = @GCOBJS@
GCSPEC = @GCSPEC@
INTERPSPEC = @INTERPSPEC@
LD = @LD@
LIBGCJ_CFLAGS = @LIBGCJ_CFLAGS@
LIBGCJ_CXXFLAGS = @LIBGCJ_CXXFLAGS@