mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-29 23:04:12 +08:00
natClassLoader.cc: Moved VMClassLoader methods...
* 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. From-SVN: r76003
This commit is contained in:
parent
280835807d
commit
b54a271561
@ -1,3 +1,10 @@
|
||||
2004-01-16 Tom Tromey <tromey@redhat.com>
|
||||
|
||||
* 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 <fnasser@redhat.com>
|
||||
|
||||
* jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c (pre_event_handler):
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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 <java/lang/InternalError.h>
|
||||
#include <java/lang/IllegalAccessError.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>
|
||||
@ -41,111 +40,6 @@ details. */
|
||||
#include <java/io/Serializable.h>
|
||||
#include <java/lang/Cloneable.h>
|
||||
|
||||
/////////// 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)
|
||||
{
|
||||
|
133
libjava/java/lang/natVMClassLoader.cc
Normal file
133
libjava/java/lang/natVMClassLoader.cc
Normal file
@ -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 <krab@gnu.org> */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <gcj/cni.h>
|
||||
#include <jvm.h>
|
||||
|
||||
#include <java-threads.h>
|
||||
#include <java-interp.h>
|
||||
|
||||
#include <java/lang/VMClassLoader.h>
|
||||
#include <gnu/gcj/runtime/VMClassLoader.h>
|
||||
#include <java/lang/ClassLoader.h>
|
||||
#include <java/lang/Class.h>
|
||||
#include <java/lang/Throwable.h>
|
||||
#include <java/security/ProtectionDomain.h>
|
||||
#include <java/lang/ClassFormatError.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user