diff --git a/libjava/ChangeLog b/libjava/ChangeLog index f181820539b6..8228be530fbf 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,10 @@ +2004-01-16 Tom Tromey + + * java/lang/natClassLoader.cc: Moved VMClassLoader methods... + * java/lang/natVMClassLoader.cc: ...here. New file. + * Makefile.in: Rebuilt. + * Makefile.am (nat_source_files): Added natVMClassLoader.cc. + 2004-01-16 Fernando Nasser * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c (pre_event_handler): diff --git a/libjava/Makefile.am b/libjava/Makefile.am index de91f8942f0a..8043a0aca0d7 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -2805,6 +2805,7 @@ java/lang/natString.cc \ java/lang/natStringBuffer.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ +java/lang/natVMClassLoader.cc \ java/lang/natVMSecurityManager.cc \ java/lang/ref/natReference.cc \ java/lang/reflect/natArray.cc \ diff --git a/libjava/Makefile.in b/libjava/Makefile.in index d6cfda3545f5..3e02fefd1167 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -2504,6 +2504,7 @@ java/lang/natString.cc \ java/lang/natStringBuffer.cc \ java/lang/natSystem.cc \ java/lang/natThread.cc \ +java/lang/natVMClassLoader.cc \ java/lang/natVMSecurityManager.cc \ java/lang/ref/natReference.cc \ java/lang/reflect/natArray.cc \ @@ -2672,12 +2673,12 @@ java/lang/natClassLoader.lo java/lang/natConcreteProcess.lo \ java/lang/natDouble.lo java/lang/natFloat.lo java/lang/natMath.lo \ java/lang/natObject.lo java/lang/natRuntime.lo java/lang/natString.lo \ java/lang/natStringBuffer.lo java/lang/natSystem.lo \ -java/lang/natThread.lo java/lang/natVMSecurityManager.lo \ -java/lang/ref/natReference.lo java/lang/reflect/natArray.lo \ -java/lang/reflect/natConstructor.lo java/lang/reflect/natField.lo \ -java/lang/reflect/natMethod.lo java/lang/reflect/natProxy.lo \ -java/net/natNetworkInterface.lo java/net/natInetAddress.lo \ -java/nio/natDirectByteBufferImpl.lo \ +java/lang/natThread.lo java/lang/natVMClassLoader.lo \ +java/lang/natVMSecurityManager.lo java/lang/ref/natReference.lo \ +java/lang/reflect/natArray.lo java/lang/reflect/natConstructor.lo \ +java/lang/reflect/natField.lo java/lang/reflect/natMethod.lo \ +java/lang/reflect/natProxy.lo java/net/natNetworkInterface.lo \ +java/net/natInetAddress.lo java/nio/natDirectByteBufferImpl.lo \ java/nio/channels/natFileChannelImpl.lo java/text/natCollator.lo \ java/util/natResourceBundle.lo java/util/natTimeZone.lo \ java/util/zip/natDeflater.lo java/util/zip/natInflater.lo @@ -3709,7 +3710,8 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/java/lang/natMath.P .deps/java/lang/natObject.P \ .deps/java/lang/natRuntime.P .deps/java/lang/natString.P \ .deps/java/lang/natStringBuffer.P .deps/java/lang/natSystem.P \ -.deps/java/lang/natThread.P .deps/java/lang/natVMSecurityManager.P \ +.deps/java/lang/natThread.P .deps/java/lang/natVMClassLoader.P \ +.deps/java/lang/natVMSecurityManager.P \ .deps/java/lang/ref/PhantomReference.P .deps/java/lang/ref/Reference.P \ .deps/java/lang/ref/ReferenceQueue.P \ .deps/java/lang/ref/SoftReference.P .deps/java/lang/ref/WeakReference.P \ diff --git a/libjava/java/lang/natClassLoader.cc b/libjava/java/lang/natClassLoader.cc index 4f15930e1ae2..f5f37faf58b7 100644 --- a/libjava/java/lang/natClassLoader.cc +++ b/libjava/java/lang/natClassLoader.cc @@ -1,6 +1,6 @@ // natClassLoader.cc - Implementation of java.lang.ClassLoader native methods. -/* Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation +/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation This file is part of libgcj. @@ -28,7 +28,6 @@ details. */ #include #include #include -#include #include #include #include @@ -41,111 +40,6 @@ details. */ #include #include -/////////// java.lang.ClassLoader native methods //////////// - -java::lang::Class * -java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader, - jstring name, - jbyteArray data, - jint offset, - jint length, - java::security::ProtectionDomain *pd) -{ -#ifdef INTERPRETER - jclass klass; - klass = (jclass) JvAllocObject (&java::lang::Class::class$, - sizeof (_Jv_InterpClass)); - - // Synchronize on the class, so that it is not attempted initialized - // until we're done loading. - JvSynchronize sync (klass); - - // Record the defining loader. For the system class loader, we - // record NULL. - if (loader != java::lang::ClassLoader::getSystemClassLoader()) - klass->loader = loader; - - if (name != 0) - { - _Jv_Utf8Const *name2 = _Jv_makeUtf8Const (name); - - if (! _Jv_VerifyClassName (name2)) - throw new java::lang::ClassFormatError - (JvNewStringLatin1 ("erroneous class name")); - - klass->name = name2; - } - - try - { - _Jv_DefineClass (klass, data, offset, length); - } - catch (java::lang::Throwable *ex) - { - klass->state = JV_STATE_ERROR; - klass->notifyAll (); - - _Jv_UnregisterClass (klass); - - // If EX is not a ClassNotFoundException, that's ok, because we - // account for the possibility in defineClass(). - throw ex; - } - - klass->protectionDomain = pd; - - // if everything proceeded sucessfully, we're loaded. - JvAssert (klass->state == JV_STATE_LOADED); - - return klass; - -#else // INTERPRETER - - return 0; -#endif -} - -// Finish linking a class. Only called from ClassLoader::resolveClass. -void -java::lang::VMClassLoader::linkClass0 (java::lang::Class *klass) -{ - _Jv_WaitForState (klass, JV_STATE_LINKED); -} - -void -java::lang::VMClassLoader::markClassErrorState0 (java::lang::Class *klass) -{ - klass->state = JV_STATE_ERROR; - klass->notifyAll (); -} - -java::lang::ClassLoader * -java::lang::VMClassLoader::getSystemClassLoaderInternal() -{ - _Jv_InitClass (&gnu::gcj::runtime::VMClassLoader::class$); - return gnu::gcj::runtime::VMClassLoader::instance; -} - -jclass -java::lang::VMClassLoader::getPrimitiveClass (jchar type) -{ - char sig[2]; - sig[0] = (char) type; - sig[1] = '\0'; - return _Jv_FindClassFromSignature (sig, NULL); -} - -jclass -java::lang::VMClassLoader::loadClass(jstring name, jboolean resolve) -{ - _Jv_Utf8Const *utf = _Jv_makeUtf8Const (name); - // FIXME: we culd make _Jv_FindClassFromSignature a template. - jclass klass = _Jv_FindClassInCache (utf, NULL); - if (klass && resolve) - _Jv_InitClass (klass); - return klass; -} - void _Jv_WaitForState (jclass klass, int state) { diff --git a/libjava/java/lang/natVMClassLoader.cc b/libjava/java/lang/natVMClassLoader.cc new file mode 100644 index 000000000000..8de0a70669e3 --- /dev/null +++ b/libjava/java/lang/natVMClassLoader.cc @@ -0,0 +1,133 @@ +// natVMClassLoader.cc - VMClassLoader native methods + +/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation + + 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 */ + +#include + +#include +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +java::lang::Class * +java::lang::VMClassLoader::defineClass (java::lang::ClassLoader *loader, + jstring name, + jbyteArray data, + jint offset, + jint length, + java::security::ProtectionDomain *pd) +{ +#ifdef INTERPRETER + jclass klass; + klass = (jclass) JvAllocObject (&java::lang::Class::class$, + sizeof (_Jv_InterpClass)); + + // Synchronize on the class, so that it is not attempted initialized + // until we're done loading. + JvSynchronize sync (klass); + + // Record the defining loader. For the system class loader, we + // record NULL. + if (loader != java::lang::ClassLoader::getSystemClassLoader()) + klass->loader = loader; + + if (name != 0) + { + _Jv_Utf8Const *name2 = _Jv_makeUtf8Const (name); + + if (! _Jv_VerifyClassName (name2)) + throw new java::lang::ClassFormatError + (JvNewStringLatin1 ("erroneous class name")); + + klass->name = name2; + } + + try + { + _Jv_DefineClass (klass, data, offset, length); + } + catch (java::lang::Throwable *ex) + { + klass->state = JV_STATE_ERROR; + klass->notifyAll (); + + _Jv_UnregisterClass (klass); + + // If EX is not a ClassNotFoundException, that's ok, because we + // account for the possibility in defineClass(). + throw ex; + } + + klass->protectionDomain = pd; + + // if everything proceeded sucessfully, we're loaded. + JvAssert (klass->state == JV_STATE_LOADED); + + return klass; + +#else // INTERPRETER + + return 0; +#endif +} + +// Finish linking a class. Only called from ClassLoader::resolveClass. +void +java::lang::VMClassLoader::linkClass0 (java::lang::Class *klass) +{ + _Jv_WaitForState (klass, JV_STATE_LINKED); +} + +void +java::lang::VMClassLoader::markClassErrorState0 (java::lang::Class *klass) +{ + klass->state = JV_STATE_ERROR; + klass->notifyAll (); +} + +java::lang::ClassLoader * +java::lang::VMClassLoader::getSystemClassLoaderInternal() +{ + _Jv_InitClass (&gnu::gcj::runtime::VMClassLoader::class$); + return gnu::gcj::runtime::VMClassLoader::instance; +} + +jclass +java::lang::VMClassLoader::getPrimitiveClass (jchar type) +{ + char sig[2]; + sig[0] = (char) type; + sig[1] = '\0'; + return _Jv_FindClassFromSignature (sig, NULL); +} + +jclass +java::lang::VMClassLoader::loadClass(jstring name, jboolean resolve) +{ + _Jv_Utf8Const *utf = _Jv_makeUtf8Const (name); + // FIXME: we culd make _Jv_FindClassFromSignature a template. + jclass klass = _Jv_FindClassInCache (utf, NULL); + if (klass && resolve) + _Jv_InitClass (klass); + return klass; +}