Edwin Steiner
Christian Thalinger
- $Id: linker.c 3292 2005-09-28 10:36:34Z twisti $
+ $Id: linker.c 3803 2005-11-26 19:18:33Z twisti $
*/
#include <assert.h>
+#include "config.h"
+#include "vm/types.h"
+
#include "mm/memory.h"
#include "native/native.h"
#include "vm/builtin.h"
interfaceindex = 0;
+ /* link java.lang.Class as first class of the system, because we
+ need it's vftbl for all other classes so we can use a class as
+ object */
+
+ if (!link_class(class_java_lang_Class))
+ return false;
+
+ /* now set the header.vftbl of all classes which were created
+ before java.lang.Class was linked */
+
+ class_postset_header_vftbl();
+
+
/* link important system classes */
if (!link_class(class_java_lang_Object))
/* load some other important classes */
- if (!link_class(class_java_lang_Class))
- return false;
-
if (!link_class(class_java_lang_ClassLoader))
return false;
throw_cacao_exception_exit(string_java_lang_InternalError,
"Trying to link unloaded class");
+ /* cache the self-reference of this class */
+ /* we do this for cases where the defining loader of the class */
+ /* has not yet been recorded as an initiating loader for the class */
+ /* this is needed so subsequent code can assume that self-refs */
+ /* will always resolve lazily */
+ /* No need to do it for the bootloader - it is always registered */
+ /* as initiating loader for the classes it loads. */
+ if (c->classloader)
+ classcache_store(c->classloader,c,false);
+
/* ok, this class is somewhat linked */
c->linked = true;
sizeof(methodptr*) * (interfacetablelength - (interfacetablelength > 0)));
v = (vftbl_t *) (((methodptr *) v) +
(interfacetablelength - 1) * (interfacetablelength > 1));
- c->header.vftbl = c->vftbl = v;
+ c->vftbl = v;
v->class = c;
v->vftbllength = vftbllength;
v->interfacetablelength = interfacetablelength;
&(m->exceptiontable[j].catchtype.cls)))
return NULL;
}
-
- for (j = 0; j < m->thrownexceptionscount; j++)
- if (!resolve_classref_or_classinfo(NULL, m->thrownexceptions[j],
- resolveEager, true, false,
- &(m->thrownexceptions[j].cls)))
- return NULL;
}
/* final tasks */
switch (c->name->text[1]) {
case '[':
/* c is an array of arrays. */
- u = utf_new_intern(c->name->text + 1, namelen - 1);
+ u = utf_new(c->name->text + 1, namelen - 1);
if (!(comp = load_class_from_classloader(u, c->classloader)))
return NULL;
break;
case 'L':
/* c is an array of objects. */
- u = utf_new_intern(c->name->text + 2, namelen - 3);
+ u = utf_new(c->name->text + 2, namelen - 3);
if (!(comp = load_class_from_classloader(u, c->classloader)))
return NULL;
break;
break;
default:
- *exceptionptr = new_classnotfoundexception(c->name);
+ *exceptionptr = new_noclassdeffounderror(c->name);
return NULL;
}