using namespace gcj;
-typedef unsigned int uaddr __attribute__ ((mode (pointer)));
-
template<typename T>
struct aligner
{
goto end_of_method_search;
}
- // Finally, search superclasses.
- for (jclass cls = owner->getSuperclass (); cls != 0;
- cls = cls->getSuperclass ())
- {
- the_method = search_method_in_class (cls, klass, method_name,
- method_signature);
- if (the_method != 0)
- {
- found_class = cls;
- break;
- }
- }
-
+ // Finally, search superclasses.
+ the_method = (search_method_in_superclasses
+ (owner->getSuperclass (), klass, method_name,
+ method_signature, &found_class));
+
end_of_method_search:
// FIXME: if (cls->loader != klass->loader), then we
}
// Find a method declared in the cls that is referenced from klass and
-// perform access checks.
+// perform access checks if CHECK_PERMS is true.
_Jv_Method *
_Jv_Linker::search_method_in_class (jclass cls, jclass klass,
_Jv_Utf8Const *method_name,
- _Jv_Utf8Const *method_signature)
+ _Jv_Utf8Const *method_signature,
+ bool check_perms)
{
using namespace java::lang::reflect;
method_signature)))
continue;
- if (_Jv_CheckAccess (klass, cls, method->accflags))
+ if (!check_perms || _Jv_CheckAccess (klass, cls, method->accflags))
return method;
else
{
return 0;
}
+// Like search_method_in_class, but work our way up the superclass
+// chain.
+_Jv_Method *
+_Jv_Linker::search_method_in_superclasses (jclass cls, jclass klass,
+ _Jv_Utf8Const *method_name,
+ _Jv_Utf8Const *method_signature,
+ jclass *found_class, bool check_perms)
+{
+ _Jv_Method *the_method = NULL;
+
+ for ( ; cls != 0; cls = cls->getSuperclass ())
+ {
+ the_method = search_method_in_class (cls, klass, method_name,
+ method_signature, check_perms);
+ if (the_method != 0)
+ {
+ if (found_class)
+ *found_class = cls;
+ break;
+ }
+ }
+
+ return the_method;
+}
#define INITIAL_IOFFSETS_LEN 4
#define INITIAL_IFACES_LEN 4
throw new java::lang::NoSuchMethodError;
}
-#ifdef USE_LIBFFI
+#if defined USE_LIBFFI && FFI_CLOSURES
// A function whose invocation is prepared using libffi. It gets called
// whenever a static method of a missing class is invoked. The data argument
// holds a reference to a String denoting the missing class.
return i;
}
-#ifdef USE_LIBFFI
+#if defined USE_LIBFFI && FFI_CLOSURES
// We use a structure of this type to store the closure that
// represents a missing method.
struct method_closure
// of the missing class then.
return (void *) _Jv_ThrowNoClassDefFoundError;
}
-#endif // USE_LIBFFI
+#endif // USE_LIBFFI && FFI_CLOSURES
// Functions for indirect dispatch (symbolic virtual binding) support.
_Jv_Method *meth = NULL;
_Jv_Utf8Const *signature = sym.signature;
+ uaddr special;
+ maybe_adjust_signature (signature, special);
if (target_class == NULL)
throw new java::lang::NoClassDefFoundError
// it out now.
wait_for_state(target_class, JV_STATE_PREPARED);
- meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
- sym.signature);
+ try
+ {
+ meth = (search_method_in_superclasses
+ (target_class, klass, sym.name, signature,
+ NULL, special == 0));
+ }
+ catch (::java::lang::IllegalAccessError *e)
+ {
+ }
// Every class has a throwNoSuchMethodErrorIndex method that
// it inherits from java.lang.Object. Find its vtable
try
{
the_field = find_field (klass, target_class, &found_class,
- sym.name, sym.signature);
+ sym.name, signature);
if ((the_field->flags & java::lang::reflect::Modifier::STATIC))
throw new java::lang::IncompatibleClassChangeError;
else
_Jv_FindClassNoException (sym.class_name, klass->loader);
_Jv_Method *meth = NULL;
+
_Jv_Utf8Const *signature = sym.signature;
+ uaddr special;
+ maybe_adjust_signature (signature, special);
// ??? Setting this pointer to null will at least get us a
// NullPointerException
// If the target class is missing we prepare a function call
// that throws a NoClassDefFoundError and store the address of
- // that newly prepare method in the atable. The user can run
+ // that newly prepared method in the atable. The user can run
// code in classes where the missing class is part of the
// execution environment as long as it is never referenced.
if (target_class == NULL)
throw new VerifyError(sb->toString());
}
- meth = _Jv_LookupDeclaredMethod(target_class, sym.name,
- sym.signature);
+ try
+ {
+ meth = (search_method_in_superclasses
+ (target_class, klass, sym.name, signature,
+ NULL, special == 0));
+ }
+ catch (::java::lang::IllegalAccessError *e)
+ {
+ }
if (meth != NULL)
{
wait_for_state(target_class, JV_STATE_PREPARED);
jclass found_class;
_Jv_Field *the_field = find_field (klass, target_class, &found_class,
- sym.name, sym.signature);
+ sym.name, signature);
if ((the_field->flags & java::lang::reflect::Modifier::STATIC))
klass->atable->addresses[index] = the_field->u.addr;
else
++index)
{
jclass target_class = _Jv_FindClass (sym.class_name, klass->loader);
+
_Jv_Utf8Const *signature = sym.signature;
+ uaddr special;
+ maybe_adjust_signature (signature, special);
jclass cls;
int i;
wait_for_state(target_class, JV_STATE_LOADED);
bool found = _Jv_getInterfaceMethod (target_class, cls, i,
- sym.name, sym.signature);
+ sym.name, signature);
if (found)
{
else
instance_size = java::lang::Object::class$.size();
+ klass->engine->allocate_field_initializers (klass);
+
for (int i = 0; i < klass->field_count; i++)
{
int field_size;
// It is safe to resolve the field here, since it's a
// primitive class, which does not cause loading to happen.
resolve_field (field, klass->loader);
-
field_size = field->type->size ();
field_align = get_alignment_from_class (field->type);
}