+2005-06-24 Tom Tromey <tromey@redhat.com>
+
+ * java/lang/natClassLoader.cc (_Jv_UnregisterClass): Handle case
+ where class' name is NULL.
+ (_Jv_FindClass): Don't wait for class state.
+ * java/lang/natVMClassLoader.cc (defineClass): Only unregister if
+ name found.
+ * include/java-interp.h (_Jv_DefineClass): Updated.
+ * defineclass.cc (_Jv_DefineClass): Added 'name_result' argument.
+ (struct _Jv_ClassReader): Likewise.
+ (found_name): New field.
+ (handleClassBegin): Set *found_name.
+ (_Jv_VerifyMethodSignature): Handle case where ptr==NULL.
+ (handleClassBegin): Throw error if super class not set.
+ (read_methods): Correctly call check_tag and prepare_pool_entry.
+
2005-06-24 Tom Tromey <tromey@redhat.com>
* boehm.cc (_Jv_MarkObj): Handle case where field's type is NULL.
* public or private members here.
*/
-struct _Jv_ClassReader {
+struct _Jv_ClassReader
+{
// do verification? Currently, there is no option to disable this.
// This flag just controls the verificaiton done by the class loader;
// the classes associated interpreter data.
_Jv_InterpClass *def_interp;
+ // The name we found.
+ _Jv_Utf8Const **found_name;
+
/* check that the given number of input bytes are available */
inline void check (int num)
{
}
_Jv_ClassReader (jclass klass, jbyteArray data, jint offset, jint length,
- java::security::ProtectionDomain *pd)
+ java::security::ProtectionDomain *pd,
+ _Jv_Utf8Const **name_result)
{
if (klass == 0 || length < 0 || offset+length > data->length)
throw_internal_error ("arguments to _Jv_DefineClass");
len = length;
pos = 0;
def = klass;
+ found_name = name_result;
def->size_in_bytes = -1;
def->vtable_method_count = -1;
*/
};
+// Note that *NAME_RESULT will only be set if the class is registered
+// with the class loader. This is how the caller can know whether
+// unregistration is require.
void
_Jv_DefineClass (jclass klass, jbyteArray data, jint offset, jint length,
- java::security::ProtectionDomain *pd)
+ java::security::ProtectionDomain *pd,
+ _Jv_Utf8Const **name_result)
{
- _Jv_ClassReader reader (klass, data, offset, length, pd);
+ _Jv_ClassReader reader (klass, data, offset, length, pd, name_result);
reader.parse();
/* that's it! */
int attributes_count = read2u ();
check_tag (name_index, JV_CONSTANT_Utf8);
- prepare_pool_entry (descriptor_index, JV_CONSTANT_Utf8);
+ prepare_pool_entry (name_index, JV_CONSTANT_Utf8);
- check_tag (name_index, JV_CONSTANT_Utf8);
+ check_tag (descriptor_index, JV_CONSTANT_Utf8);
prepare_pool_entry (descriptor_index, JV_CONSTANT_Utf8);
handleMethod (i, access_flags, name_index,
pool_data[this_class].clazz = def;
pool_tags[this_class] = JV_CONSTANT_ResolvedClass;
- if (super_class == 0 && ! (access_flags & Modifier::INTERFACE))
+ if (super_class == 0)
{
- // FIXME: Consider this carefully!
- if (! _Jv_equalUtf8Consts (def->name, java::lang::Object::class$.name))
- throw_no_class_def_found_error ("loading java.lang.Object");
+ // Note that this is ok if we are defining java.lang.Object.
+ // But there is no way to have this class be interpreted.
+ throw_class_format_error ("no superclass reference");
}
def->state = JV_STATE_PRELOADING;
// lock here, as our caller has acquired it.
_Jv_RegisterInitiatingLoader (def, def->loader);
+ // Note that we found a name so that unregistration can happen if
+ // needed.
+ *found_name = def->name;
+
+ jclass the_super = NULL;
if (super_class != 0)
{
// Load the superclass.
_Jv_Utf8Const* super_name = pool_data[super_class].utf8;
// Load the superclass using our defining loader.
- jclass the_super = _Jv_FindClass (super_name,
- def->loader);
+ jclass the_super = _Jv_FindClass (super_name, def->loader);
// This will establish that we are allowed to be a subclass,
// and check for class circularity error.
while (ptr && UTF8_PEEK (ptr, limit) != ')')
ptr = _Jv_VerifyOne (ptr, limit, false);
- if (UTF8_GET (ptr, limit) != ')')
+ if (! ptr || UTF8_GET (ptr, limit) != ')')
return false;
// get the return type