// natClass.cc - Implementation of java.lang.Class native methods.
-/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation
+/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Free Software Foundation
This file is part of libgcj.
#include <java-cpool.h>
#include <java-interp.h>
+
\f
using namespace gcj;
+bool gcj::verbose_class_flag;
+
jclass
java::lang::Class::forName (jstring className, jboolean initialize,
java::lang::ClassLoader *loader)
jsize length = _Jv_GetStringUTFLength (className);
char buffer[length];
- _Jv_GetStringUTFRegion (className, 0, length, buffer);
+ _Jv_GetStringUTFRegion (className, 0, className->length(), buffer);
_Jv_Utf8Const *name = _Jv_makeUtf8Const (buffer, length);
// `null' instead.
if (isPrimitive ())
return NULL;
- return loader ? loader : ClassLoader::getSystemClassLoader ();
+ return loader ? loader : ClassLoader::systemClassLoader;
}
java::lang::reflect::Constructor *
_Jv_Method *meth = _Jv_GetMethodLocal (this, init_name, void_signature);
if (! meth)
- throw new java::lang::NoSuchMethodException (_Jv_NewStringUtf8Const (init_name));
+ throw new java::lang::InstantiationException (getName());
- jobject r = JvAllocObject (this);
+ jobject r = _Jv_AllocObject (this);
((void (*) (jobject)) meth->ncode) (r);
return r;
}
JArray<jobject> *
java::lang::Class::getSigners()
{
- return signers;
+ return hack_signers;
}
void
java::lang::Class::setSigners(JArray<jobject> *s)
{
- signers = s;
+ hack_signers = s;
}
// Functions for indirect dispatch (symbolic virtual binding) support.
throw new java::lang::AbstractMethodError();
}
+// Set itable method indexes for members of interface IFACE.
+void
+_Jv_LayoutInterfaceMethods (jclass iface)
+{
+ if (! iface->isInterface())
+ return;
+
+ // itable indexes start at 1.
+ // FIXME: Static initalizers currently get a NULL placeholder entry in the
+ // itable so they are also assigned an index here.
+ for (int i = 0; i < iface->method_count; i++)
+ iface->methods[i].index = i + 1;
+}
+
// Prepare virtual method declarations in KLASS, and any superclasses as
// required, by determining their vtable index, setting method->index, and
// finally setting the class's vtable_method_count. Must be called with the
if (! _Jv_isVirtualMethod (meth))
continue;
+ // FIXME: Must check that we don't override:
+ // - Package-private method where superclass is in different package.
+ // - Final or less-accessible declaration in superclass (check binary
+ // spec, do we allocate new vtable entry or put throw node in vtable?)
+ // - Static or private method in superclass.
+
if (superclass != NULL)
{
super_meth = _Jv_LookupDeclaredMethod (superclass, meth->name,
if (super_meth)
meth->index = super_meth->index;
- else if (! (meth->accflags & java::lang::reflect::Modifier::FINAL)
- && ! (klass->accflags & java::lang::reflect::Modifier::FINAL))
+ else
meth->index = index++;
}
|| (klass->accflags & Modifier::ABSTRACT))
return;
- // out before we can create a vtable.
+ // Class must be laid out before we can create a vtable.
if (klass->vtable_method_count == -1)
_Jv_LayoutVTableMethods (klass);