Changes: Christian Thalinger
- $Id: native.c 3445 2005-10-19 11:28:41Z twisti $
+ $Id: native.c 3801 2005-11-26 19:15:45Z twisti $
*/
#endif /* defined(ENABLE_STATICVM) */
-/************* use classinfo structure as java.lang.Class object **************/
-
-bool use_class_as_object(classinfo *c)
-{
- if (!c->classvftbl) {
- /* is the class loaded */
- if (!c->loaded) {
-/* if (!class_load(c)) */
-/* throw_exception_exit(); */
- log_text("use_class_as_object: class_load should not happen");
- assert(0);
- }
-
- /* is the class linked */
- if (!c->linked)
- if (!link_class(c))
- return false;
-
- assert(class_java_lang_Class);
-
- c->header.vftbl = class_java_lang_Class->vftbl;
- c->classvftbl = true;
- }
-
- return true;
-}
-
-
/************************** tables for methods ********************************/
#undef JOWENN_DEBUG
/* get classes */
- for (i = 0; i < paramcount; i++) {
+ for (i = 0; i < paramcount; i++)
if (!resolve_class_from_typedesc(¶mtypes[i], true, false,
(classinfo **) &oa->data[i]))
return NULL;
- use_class_as_object((classinfo *) oa->data[i]);
- }
-
return oa;
}
resolveEager, true, false, &c))
return NULL;
- if (!use_class_as_object(c))
- return NULL;
-
oa->data[i] = (java_objectheader *) c;
}
&c))
return NULL;
- use_class_as_object(c);
-
return c;
}
Changes: Joseph Wenninger
Christian Thalinger
- $Id: Field.c 3672 2005-11-15 23:43:17Z twisti $
+ $Id: Field.c 3801 2005-11-26 19:15:45Z twisti $
*/
if (!resolve_class_from_typedesc(desc, true, false, &ret))
return NULL;
- if (!use_class_as_object(ret))
- return NULL;
-
return (java_lang_Class *) ret;
}
Changes: Joseph Wenninger
Christian Thalinger
- $Id: VMClass.c 3649 2005-11-10 22:05:22Z twisti $
+ $Id: VMClass.c 3801 2005-11-26 19:15:45Z twisti $
*/
if (!initialize_class(c))
return NULL;
- if (!use_class_as_object(c))
- return NULL;
-
return (java_lang_Class *) c;
}
else
comp = primitivetype_table[desc->arraytype].class_primitive;
- /* set vftbl */
-
- if (!use_class_as_object(comp))
- return NULL;
-
return (java_lang_Class *) comp;
}
&inner))
return NULL;
- if (!use_class_as_object(inner))
- return NULL;
+ if (!inner->linked)
+ if (!link_class(inner))
+ return NULL;
oa->data[pos++] = (java_objectheader *) inner;
}
&outer))
return NULL;
- if (!use_class_as_object(outer))
- return NULL;
+ if (!outer->linked)
+ if (!link_class(outer))
+ return NULL;
return (java_lang_Class *) outer;
}
JNIEXPORT java_objectarray* JNICALL Java_java_lang_VMClass_getInterfaces(JNIEnv *env, jclass clazz, java_lang_Class *klass)
{
classinfo *c;
+ classinfo *ic;
java_objectarray *oa;
u4 i;
c = (classinfo *) klass;
+ if (!c->linked)
+ if (!link_class(c))
+ return NULL;
+
oa = builtin_anewarray(c->interfacescount, class_java_lang_Class);
if (!oa)
return NULL;
for (i = 0; i < c->interfacescount; i++) {
- if (!use_class_as_object(c->interfaces[i].cls))
- return NULL;
+ ic = c->interfaces[i].cls;
- oa->data[i] = (java_objectheader *) c->interfaces[i].cls;
+ oa->data[i] = (java_objectheader *) ic;
}
return oa;
if (!sc)
return NULL;
- if (!use_class_as_object(sc))
- return NULL;
-
return (java_lang_Class *) sc;
}
{
classinfo *c = (classinfo *) klass;
+ if (!c->linked)
+ if (!link_class(c))
+ return 0;
+
return (c->vftbl->arraydesc != NULL);
}
*/
JNIEXPORT s4 JNICALL Java_java_lang_VMClass_isAssignableFrom(JNIEnv *env, jclass clazz, java_lang_Class *klass, java_lang_Class *c)
{
- if (c == NULL) {
+ classinfo *kc;
+ classinfo *cc;
+
+ kc = (classinfo *) klass;
+ cc = (classinfo *) c;
+
+ if (cc == NULL) {
*exceptionptr = new_nullpointerexception();
return 0;
}
+ if (!kc->linked)
+ if (!link_class(kc))
+ return 0;
+
+ if (!cc->linked)
+ if (!link_class(cc))
+ return 0;
+
/* XXX this may be wrong for array classes */
- return builtin_isanysubclass((classinfo *) c, (classinfo *) klass);
+
+ return builtin_isanysubclass(cc, kc);
}
c = (classinfo *) klass;
ob = (java_objectheader *) o;
+ if (!c->linked)
+ if (!link_class(c))
+ return 0;
+
return builtin_instanceof(ob, c);
}
Christian Thalinger
Edwin Steiner
- $Id: VMClassLoader.c 3559 2005-11-04 09:57:34Z twisti $
+ $Id: VMClassLoader.c 3801 2005-11-26 19:15:45Z twisti $
*/
c->pd = pd;
- if (!use_class_as_object(c))
- return NULL;
-
/* Store the newly defined class in the class cache. This call also */
/* checks whether a class of the same name has already been defined by */
/* the same defining loader, and if so, replaces the newly created class */
c = NULL;
}
-#if 0
- /* XXX TWISTI is this neccessary? */
- if (!initialize_class(c))
- return NULL;
-#endif
-
- use_class_as_object(c);
-
return (java_lang_Class *) c;
}
/* if (resolve) { */
if (!link_class(c))
goto exception;
-
- use_class_as_object(c);
/* } */
return (java_lang_Class *) c;
Changes: Joseph Wenninger
Christian Thalinger
- $Id: VMObject.c 3079 2005-07-20 15:23:18Z twisti $
+ $Id: VMObject.c 3801 2005-11-26 19:15:45Z twisti $
*/
c = ((java_objectheader *) obj)->vftbl->class;
- use_class_as_object(c);
-
return (java_lang_Class *) c;
}
calls instead of machine instructions, using the C calling
convention.
- $Id: builtin.c 3654 2005-11-11 11:17:33Z twisti $
+ $Id: builtin.c 3801 2005-11-26 19:15:45Z twisti $
*/
#if defined(USE_THREADS)
/*
* Locks the class object - needed for static synchronized methods.
- * The use_class_as_object call is needed in order to circumvent a
- * possible deadlock with builtin_monitorenter called by another
- * thread calling use_class_as_object.
*/
void builtin_staticmonitorenter(classinfo *c)
{
- use_class_as_object(c);
builtin_monitorenter(&c->header);
}
#endif
Joseph Wenninger
Christian Thalinger
- $Id: parse.c 3615 2005-11-07 18:22:11Z twisti $
+ $Id: parse.c 3801 2005-11-26 19:15:45Z twisti $
*/
true, &c))
return NULL;
- /* XXX TWISTI: edwin said i should do that */
-
- if (c)
- if (!use_class_as_object(c))
- return NULL;
-
/* if not resolved, c == NULL */
LOADCONST_A_CLASS(c, cr);
Changes: Christian Thalinger
- $Id: stacktrace.c 3779 2005-11-23 22:36:59Z twisti $
+ $Id: stacktrace.c 3801 2005-11-26 19:15:45Z twisti $
*/
continue;
}
- use_class_as_object(current->method->class);
-
oa->data[i] = (java_objectheader *) current->method->class;
}
for (i = 0, current = &(buffer->start[0]); i < size; i++, current++) {
c = current->method->class;
- use_class_as_object(c);
-
classes->data[i] = (java_objectheader *) c;
str = javastring_new(current->method->name);
Changes:
- $Id: patcher.c 3708 2005-11-18 00:30:10Z twisti $
+ $Id: patcher.c 3801 2005-11-26 19:15:45Z twisti $
*/
return false;
}
- if (!use_class_as_object(c)) {
- PATCHER_MONITOREXIT;
-
- return false;
- }
-
/* patch back original code */
*((u8 *) ra) = mcode;