Edwin Steiner
Christian Thalinger
- $Id: linker.c 2788 2005-06-22 16:08:51Z edwin $
+ $Id: linker.c 3685 2005-11-16 13:28:59Z twisti $
*/
#include <assert.h>
+#include "config.h"
+#include "vm/types.h"
+
#include "mm/memory.h"
#include "native/native.h"
#include "vm/builtin.h"
primitive class.
CAUTION: Don't change the order of the types. This table is indexed
- by the ARRAYTYPE_ constants (expcept ARRAYTYPE_OBJECT).
+ by the ARRAYTYPE_ constants (except ARRAYTYPE_OBJECT).
*******************************************************************************/
if (!link_class(class_java_lang_System))
return false;
+ if (!link_class(class_java_lang_Thread))
+ return false;
+
if (!link_class(class_java_lang_ThreadGroup))
return false;
+ if (!link_class(class_java_lang_VMThread))
+ return false;
+
/* some classes which may be used more often */
assert(0);
}
- if (!link_class(pseudo_class_Arraystub))
+ if (!link_class(pseudo_class_Arraystub))
return false;
- /* pseudo class representing the null type */
+ /* pseudo class representing the null type */
pseudo_class_Null = class_create_classinfo(utf_new_char("$NULL$"));
pseudo_class_Null->loaded = true;
- pseudo_class_Null->super.cls = class_java_lang_Object;
+ pseudo_class_Null->super.cls = class_java_lang_Object;
if (!classcache_store_unique(pseudo_class_Null)) {
log_text("could not cache pseudo_class_Null");
if (!link_class(pseudo_class_Null))
return false;
- /* pseudo class representing new uninitialized objects */
+ /* pseudo class representing new uninitialized objects */
pseudo_class_New = class_create_classinfo(utf_new_char("$NEW$"));
pseudo_class_New->loaded = true;
/* create primitive class */
c = class_create_classinfo(utf_new_char(primitivetype_table[i].name));
+
+ c->flags = ACC_PUBLIC | ACC_FINAL | ACC_ABSTRACT;
c->classUsed = NOTUSED; /* not used initially CO-RT */
c->impldBy = NULL;
/* prevent loader from loading primitive class */
c->loaded = true;
- if (!classcache_store_unique(c)) {
- log_text("Could not cache primitive class");
- return false;
- }
+
+ /* INFO: don't put primitive classes into the classcache */
+
if (!link_class(c))
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;
/* Methods in ABSTRACT classes from interfaces maybe already have a */
/* stubroutine. */
- if (!m->stubroutine) {
- if (!(m->flags & ACC_NATIVE)) {
- m->stubroutine = createcompilerstub(m);
-
- } else {
- functionptr f = NULL;
-
-#if defined(STATIC_CLASSPATH)
- f = native_findfunction(c->name, m->name, m->descriptor,
- (m->flags & ACC_STATIC));
- if (f)
-#endif
- m->stubroutine = codegen_createnativestub(f, m);
- }
- }
+ if (!m->stubroutine)
+ m->stubroutine = createcompilerstub(m);
if (!(m->flags & ACC_STATIC))
v->table[m->vftblindex] = (methodptr) (ptrint) m->stubroutine;
&(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:
- log_text("Invalid array class name");
- assert(0);
+ *exceptionptr = new_noclassdeffounderror(c->name);
+ return NULL;
}
desc->componentvftbl = NULL;