// natClassLoader.cc - Implementation of java.lang.ClassLoader native methods.
-/* Copyright (C) 1999, 2000, 2001 Free Software Foundation
+/* Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation
This file is part of libgcj.
#include <config.h>
#include <stdlib.h>
+#include <stdio.h>
#include <string.h>
#include <gcj/cni.h>
#include <jvm.h>
+#include <execution.h>
#include <java-threads.h>
#include <java-interp.h>
#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>
#include <java/lang/IncompatibleClassChangeError.h>
+#include <java/lang/ClassFormatError.h>
+#include <java/lang/VirtualMachineError.h>
+#include <java/lang/VMClassLoader.h>
#include <java/lang/reflect/Modifier.h>
#include <java/lang/Runtime.h>
#include <java/lang/StringBuffer.h>
#include <java/io/Serializable.h>
#include <java/lang/Cloneable.h>
-
-// FIXME: remove these.
-#define CloneableClass java::lang::Cloneable::class$
-#define ObjectClass java::lang::Object::class$
-#define ClassClass java::lang::Class::class$
-#define VMClassLoaderClass gnu::gcj::runtime::VMClassLoader::class$
-#define ClassLoaderClass java::lang::ClassLoader::class$
-#define SerializableClass java::io::Serializable::class$
-
-/////////// java.lang.ClassLoader native methods ////////////
-
-java::lang::Class *
-java::lang::ClassLoader::defineClass0 (jstring name,
- jbyteArray data,
- jint offset,
- jint length,
- java::security::ProtectionDomain *pd)
-{
-#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);
-
- 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);
-
- _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.
-
- // FIXME: Rewrite this as a cleanup instead of
- // as a catch handler.
-
- throw ex;
- }
-
- klass->protectionDomain = pd;
-
- // 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)
- {
- // Must call _Jv_PrepareCompiledClass while holding the class
- // mutex.
- _Jv_PrepareCompiledClass (klass);
- _Jv_MonitorExit (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)
- 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_PrepareCompiledClass (klass);
-}
-
-void
-java::lang::ClassLoader::markClassErrorState0 (java::lang::Class *klass)
-{
- klass->state = JV_STATE_ERROR;
- klass->notifyAll ();
-}
-
-
-// This is the findClass() implementation for the System classloader. It is
-// the only native method in VMClassLoader, so we define it here.
-jclass
-gnu::gcj::runtime::VMClassLoader::findClass (jstring name)
-{
- _Jv_Utf8Const *name_u = _Jv_makeUtf8Const (name);
- jclass klass = _Jv_FindClassInCache (name_u, 0);
-
- if (! klass)
- {
- // Turn `gnu.pkg.quux' into `lib-gnu-pkg-quux'. Then search for
- // a module named (eg, on Linux) `lib-gnu-pkg-quux.so', followed
- // by `lib-gnu-pkg.so' and `lib-gnu.so'. If loading one of
- // these causes the class to appear in the cache, then use it.
- java::lang::StringBuffer *sb = new java::lang::StringBuffer (JvNewStringLatin1("lib-"));
- jstring so_base_name = (sb->append (name)->toString ())->replace ('.', '-');
-
- while (! klass && so_base_name && so_base_name->length() > 0)
- {
- using namespace ::java::lang;
- Runtime *rt = Runtime::getRuntime();
- jboolean loaded = rt->loadLibraryInternal (so_base_name);
-
- jint nd = so_base_name->lastIndexOf ('-');
- if (nd == -1)
- so_base_name = NULL;
- else
- so_base_name = so_base_name->substring (0, nd);
-
- if (loaded)
- klass = _Jv_FindClassInCache (name_u, 0);
- }
- }
-
- // Now try loading using the interpreter.
- if (! klass)
- {
- klass = java::net::URLClassLoader::findClass (name);
- }
-
- return klass;
-}
-
-jclass
-java::lang::ClassLoader::findLoadedClass (jstring name)
-{
- return _Jv_FindClassInCache (_Jv_makeUtf8Const (name), this);
-}
-
-
-/** This function does class-preparation for compiled classes.
- NOTE: It contains replicated functionality from
- _Jv_ResolvePoolEntry, and this is intentional, since that function
- lives in resolve.cc which is entirely conditionally compiled.
- */
-void
-_Jv_PrepareCompiledClass (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 index = 1; index < pool->size; ++index)
- {
- if (pool->tags[index] == JV_CONSTANT_Class)
- {
- _Jv_Utf8Const *name = pool->data[index].utf8;
-
- jclass found;
- if (name->data[0] == '[')
- found = _Jv_FindClassFromSignature (&name->data[0],
- klass->loader);
- else
- found = _Jv_FindClass (name, klass->loader);
-
- if (! found)
- {
- jstring str = _Jv_NewStringUTF (name->data);
- throw new java::lang::ClassNotFoundException (str);
- }
-
- pool->data[index].clazz = found;
- pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
- }
- else if (pool->tags[index] == JV_CONSTANT_String)
- {
- jstring str;
- str = _Jv_NewStringUtf8Const (pool->data[index].utf8);
- pool->data[index].o = str;
- pool->tags[index] |= JV_CONSTANT_ResolvedFlag;
- }
- }
-
-#ifdef INTERPRETER
- // FIXME: although the comment up top says that this function is
- // only called for compiled classes, it is actually called for every
- // class.
- if (! _Jv_IsInterpretedClass (klass))
- {
-#endif /* INTERPRETER */
- jfieldID f = JvGetFirstStaticField (klass);
- for (int n = JvNumStaticFields (klass); n > 0; --n)
- {
- int mod = f->getModifiers ();
- // Maybe the compiler should mark these with
- // _Jv_FIELD_CONSTANT_VALUE? For now we just know that this
- // only happens for constant strings.
- if (f->getClass () == &StringClass
- && java::lang::reflect::Modifier::isStatic (mod)
- && java::lang::reflect::Modifier::isFinal (mod))
- {
- jstring *strp = (jstring *) f->u.addr;
- if (*strp)
- *strp = _Jv_NewStringUtf8Const ((_Jv_Utf8Const *) *strp);
- }
- f = f->getNextField ();
- }
-#ifdef INTERPRETER
- }
-#endif /* INTERPRETER */
-
- 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.
-//
-
+#include <java/util/HashMap.h>
// 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;
-};
+#define HASH_UTF(Utf) ((Utf)->hash16() % HASH_LEN)
-static _Jv_LoaderInfo *initiated_classes[HASH_LEN];
static jclass loaded_classes[HASH_LEN];
// This is the root of a linked list of classes
+static jclass stack_head;
+
+// While bootstrapping we keep a list of classes we found, so that we
+// can register their packages. There aren't many of these so we
+// just keep a small buffer here and abort if we overflow.
+#define BOOTSTRAP_CLASS_LIST_SIZE 20
+static jclass bootstrap_class_list[BOOTSTRAP_CLASS_LIST_SIZE];
+static int bootstrap_index;
+
\f
+// This tries to find a class in our built-in cache. This cache is
+// used only for classes which are linked in to the executable or
+// loaded via dlopen().
jclass
-_Jv_FindClassInCache (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
+_Jv_FindClassInCache (_Jv_Utf8Const *name)
{
- _Jv_MonitorEnter (&ClassClass);
+ JvSynchronize sync (&java::lang::Class::class$);
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)
+ for (klass = loaded_classes[hash]; klass; klass = klass->next_or_version)
{
- if (loader == klass->loader && _Jv_equalUtf8Consts (name, klass->name))
+ if (_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);
+ JvSynchronize sync (&java::lang::Class::class$);
jint hash = HASH_UTF(the_class->name);
jclass *klass = &(loaded_classes[hash]);
- for ( ; *klass; klass = &((*klass)->next))
+ for ( ; *klass; klass = &((*klass)->next_or_version))
{
if (*klass == the_class)
{
- *klass = (*klass)->next;
+ *klass = (*klass)->next_or_version;
break;
}
}
-
- _Jv_LoaderInfo **info = &(initiated_classes[hash]);
- for ( ; ; info = &((*info)->next))
- {
- while (*info && (*info)->klass == the_class)
- {
- *info = (*info)->next;
- }
-
- if (*info == NULL)
- break;
- }
-
- _Jv_MonitorExit (&ClassClass);
}
+// Register an initiating class loader for a given class.
void
_Jv_RegisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
{
- // non-gc alloc!
- _Jv_LoaderInfo *info = (_Jv_LoaderInfo *) _Jv_Malloc (sizeof(_Jv_LoaderInfo));
- 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);
+ if (! loader)
+ loader = java::lang::ClassLoader::getSystemClassLoader();
+ loader->loadedClasses->put(klass->name->toString(), klass);
}
-// 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.
+// If we found an error while defining an interpreted class, we must
+// go back and unregister it.
void
-_Jv_RegisterClasses (jclass *classes)
+_Jv_UnregisterInitiatingLoader (jclass klass, java::lang::ClassLoader *loader)
{
- static bool init = false;
-
- if (! init)
- {
- init = true;
- _Jv_InitThreads ();
- _Jv_InitGC ();
- _Jv_InitializeSyncMutex ();
- }
+ if (! loader)
+ loader = java::lang::ClassLoader::getSystemClassLoader();
+ loader->loadedClasses->remove(klass->name->toString());
+}
- JvSynchronize sync (&ClassClass);
+// This function is called many times during startup, before main() is
+// run. At that point in time we know for certain we are running
+// single-threaded, so we don't need to lock when adding classes to the
+// class chain. At all other times, the caller should synchronize on
+// Class::class$.
+void
+_Jv_RegisterClasses (const jclass *classes)
+{
for (; *classes; ++classes)
{
jclass klass = *classes;
- (*_Jv_RegisterClassHook) (klass);
+ if (_Jv_CheckABIVersion ((unsigned long) klass->next_or_version))
+ (*_Jv_RegisterClassHook) (klass);
+ }
+}
- // registering a compiled class causes
- // it to be immediately "prepared".
- if (klass->state == JV_STATE_NOTHING)
- klass->state = JV_STATE_COMPILED;
+// This is a version of _Jv_RegisterClasses that takes a count.
+void
+_Jv_RegisterClasses_Counted (const jclass * classes, size_t count)
+{
+ size_t i;
+ for (i = 0; i < count; i++)
+ {
+ jclass klass = classes[i];
+
+ if (_Jv_CheckABIVersion ((unsigned long) klass->next_or_version))
+ (*_Jv_RegisterClassHook) (klass);
}
}
_Jv_RegisterClassHookDefault (jclass klass)
{
jint hash = HASH_UTF (klass->name);
- klass->next = loaded_classes[hash];
+
+ // If the class is already registered, don't re-register it.
+ for (jclass check_class = loaded_classes[hash];
+ check_class != NULL;
+ check_class = check_class->next_or_version)
+ {
+ if (check_class == klass)
+ {
+ // If you get this, it means you have the same class in two
+ // different libraries.
+#define TEXT "Duplicate class registration: "
+ // We size-limit MESSAGE so that you can't trash the stack.
+ char message[200];
+ strcpy (message, TEXT);
+ strncpy (message + sizeof (TEXT) - 1, klass->name->chars(),
+ sizeof (message) - sizeof (TEXT));
+ message[sizeof (message) - 1] = '\0';
+ if (! gcj::runtimeInitialized)
+ JvFail (message);
+ else
+ {
+ java::lang::String *str = JvNewStringLatin1 (message);
+ throw new java::lang::VirtualMachineError (str);
+ }
+ }
+ }
+
+ // FIXME: this is really bogus!
+ if (! klass->engine)
+ klass->engine = &_Jv_soleCompiledEngine;
+ klass->next_or_version = loaded_classes[hash];
loaded_classes[hash] = klass;
}
jclass
_Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader)
{
- jclass klass = _Jv_FindClassInCache (name, loader);
+ // See if the class was already loaded by this loader. This handles
+ // initiating loader checks, as we register classes with their
+ // initiating loaders.
+ java::lang::ClassLoader *sys
+ = java::lang::ClassLoader::getSystemClassLoader ();
+ java::lang::ClassLoader *real = loader;
+ if (! real)
+ real = sys;
+ jstring sname = name->toString();
+ // We might still be bootstrapping the VM, in which case there
+ // won't be a system class loader yet.
+ jclass klass = real ? real->findLoadedClass (sname) : NULL;
if (! klass)
{
- jstring sname = _Jv_NewStringUTF (name->data);
-
if (loader)
{
// Load using a user-defined loader, jvmspec 5.3.2
// If "loader" delegated the loadClass operation to another
// loader, explicitly register that it is also an initiating
// loader of the given class.
- if (klass && (klass->getClassLoader () != loader))
+ java::lang::ClassLoader *delegate = (loader == sys
+ ? NULL
+ : loader);
+ if (klass && klass->getClassLoaderInternal () != delegate)
_Jv_RegisterInitiatingLoader (klass, loader);
}
- else
+ else if (sys)
{
- java::lang::ClassLoader *sys
- = java::lang::ClassLoader::getSystemClassLoader ();
-
// Load using the bootstrap loader jvmspec 5.3.1.
klass = sys->loadClass (sname, false);
if (klass)
_Jv_RegisterInitiatingLoader (klass, 0);
}
+ else
+ {
+ // Not even a bootstrap loader, try the built-in cache.
+ klass = _Jv_FindClassInCache (name);
+
+ if (bootstrap_index == BOOTSTRAP_CLASS_LIST_SIZE)
+ abort ();
+ bootstrap_class_list[bootstrap_index++] = klass;
+ }
}
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);
+ _Jv_Linker::wait_for_state (klass, JV_STATE_LOADED);
}
return klass;
}
+void
+_Jv_RegisterBootstrapPackages ()
+{
+ for (int i = 0; i < bootstrap_index; ++i)
+ java::lang::VMClassLoader::definePackageForNative(bootstrap_class_list[i]->getName());
+}
+
jclass
_Jv_NewClass (_Jv_Utf8Const *name, jclass superclass,
java::lang::ClassLoader *loader)
{
- jclass ret = (jclass) JvAllocObject (&ClassClass);
-
- ret->next = NULL;
+ jclass ret = (jclass) _Jv_AllocObject (&java::lang::Class::class$);
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 = JV_STATE_NOTHING;
- ret->thread = NULL;
- ret->depth = 0;
- ret->ancestors = NULL;
- ret->idt = NULL;
- ret->arrayclass = NULL;
_Jv_RegisterClass (ret);
return;
if (element->isPrimitive())
- len = 3;
+ {
+ if (element == JvPrimClass (void))
+ throw new java::lang::ClassNotFoundException ();
+ len = 3;
+ }
else
- len = element->name->length + 5;
+ len = element->name->len() + 5;
{
char signature[len];
}
else
{
- size_t length = element->name->length;
- const char *const name = element->name->data;
+ size_t length = element->name->len();
+ const char *const name = element->name->chars();
if (name[0] != '[')
signature[index++] = 'L';
memcpy (&signature[index], name, length);
}
// Create new array class.
- jclass array_class = _Jv_NewClass (array_name, &ObjectClass,
+ jclass array_class = _Jv_NewClass (array_name, &java::lang::Object::class$,
element->loader);
// Note that `vtable_method_count' doesn't include the initial
// gc_descr slot.
- JvAssert (ObjectClass.vtable_method_count == NUM_OBJECT_METHODS);
- int dm_count = ObjectClass.vtable_method_count;
-
- // 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 *)));
+ JvAssert (java::lang::Object::class$.vtable_method_count
+ == NUM_OBJECT_METHODS);
+ int dm_count = java::lang::Object::class$.vtable_method_count;
+
+ // Create a new vtable by copying Object's vtable.
_Jv_VTable *vtable;
if (array_vtable)
vtable = array_vtable;
else
- vtable = (_Jv_VTable *) _Jv_AllocBytes (size);
+ vtable = _Jv_VTable::new_vtable (dm_count);
vtable->clas = array_class;
- memcpy (vtable->method, ObjectClass.vtable->method,
- dm_count * sizeof (void *));
- vtable->gc_descr = ObjectClass.vtable->gc_descr;
+ vtable->gc_descr = java::lang::Object::class$.vtable->gc_descr;
+ for (int i = 0; i < dm_count; ++i)
+ vtable->set_method (i, java::lang::Object::class$.vtable->get_method (i));
+
array_class->vtable = vtable;
- array_class->vtable_method_count = ObjectClass.vtable_method_count;
+ array_class->vtable_method_count
+ = java::lang::Object::class$.vtable_method_count;
// Stash the pointer to the element type.
array_class->methods = (_Jv_Method *) element;
// Register our interfaces.
- static jclass interfaces[] = { &CloneableClass, &SerializableClass };
+ static jclass interfaces[] =
+ {
+ &java::lang::Cloneable::class$,
+ &java::io::Serializable::class$
+ };
array_class->interfaces = interfaces;
array_class->interface_count = sizeof interfaces / sizeof interfaces[0];
// Since all array classes have the same interface dispatch table, we can
- // cache one and reuse it. It is not neccessary to synchronize this.
+ // cache one and reuse it. It is not necessary to synchronize this.
if (!array_idt)
{
- _Jv_PrepareConstantTimeTables (array_class);
+ _Jv_Linker::wait_for_state(array_class, JV_STATE_PREPARED);
array_idt = array_class->idt;
array_depth = array_class->depth;
array_ancestors = array_class->ancestors;
using namespace java::lang::reflect;
{
- // Array classes are "abstract final"...
- _Jv_ushort accflags = Modifier::FINAL | Modifier::ABSTRACT;
- // ... and inherit accessibility from element type, per vmspec 5.3.3.2
- accflags |= (element->accflags & Modifier::PUBLIC);
- accflags |= (element->accflags & Modifier::PROTECTED);
- accflags |= (element->accflags & Modifier::PRIVATE);
+ // Array classes are "abstract final" and inherit accessibility
+ // from element type, per vmspec 5.3.3.2
+ _Jv_ushort accflags = (Modifier::FINAL | Modifier::ABSTRACT
+ | (element->accflags
+ & (Modifier::PUBLIC | Modifier::PROTECTED
+ | Modifier::PRIVATE)));
array_class->accflags = accflags;
}
// An array class has no visible instance fields. "length" is invisible to
// reflection.
- // say this class is initialized and ready to go!
+ // Say this class is initialized and ready to go!
array_class->state = JV_STATE_DONE;
// vmspec, section 5.3.3 describes this
element->arrayclass = array_class;
}
+
+// These two functions form a stack of classes. When a class is loaded
+// it is pushed onto the stack by the class loader; this is so that
+// StackTrace can quickly determine which classes have been loaded.
+
+jclass
+_Jv_PopClass (void)
+{
+ JvSynchronize sync (&java::lang::Class::class$);
+ if (stack_head)
+ {
+ jclass tmp = stack_head;
+ stack_head = tmp->chain;
+ return tmp;
+ }
+ return NULL;
+}
+
+void
+_Jv_PushClass (jclass k)
+{
+ JvSynchronize sync (&java::lang::Class::class$);
+ jclass tmp = stack_head;
+ stack_head = k;
+ k->chain = tmp;
+}