re PR libgcj/7060 (getMethod() doesn't search super interface)

2002-07-04  Tom Tromey  <tromey@redhat.com>
            Jeff Sturm  <jsturm@one-point.com>

	Fix for PR libgcj/7060:
	* java/lang/Class.h (_getMethod): Renamed from getMethod.
	* java/lang/natClass.cc (_getMethod): Renamed from getMethod.
	Recurse into superinterfaces.  Don't throw NoSuchMethodException.
	* java/lang/Class.java (getMethod): New Java implementation;
	complies with spec.
	(_getMethod): New native method.

Co-Authored-By: Jeff Sturm <jsturm@one-point.com>

From-SVN: r55266
This commit is contained in:
Tom Tromey 2002-07-05 20:40:11 +00:00 committed by Tom Tromey
parent 9833f6792a
commit 0d49ec1158
4 changed files with 51 additions and 5 deletions

View file

@ -485,7 +485,7 @@ java::lang::Class::getInterfaces (void)
}
java::lang::reflect::Method *
java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
java::lang::Class::_getMethod (jstring name, JArray<jclass> *param_types)
{
jstring partial_sig = getSignature (param_types, false);
jint p_len = partial_sig->length();
@ -514,7 +514,21 @@ java::lang::Class::getMethod (jstring name, JArray<jclass> *param_types)
}
}
}
throw new java::lang::NoSuchMethodException;
// If we haven't found a match, and this class is an interface, then
// check all the superinterfaces.
if (isInterface())
{
for (int i = 0; i < interface_count; ++i)
{
using namespace java::lang::reflect;
Method *rmethod = interfaces[i]->_getMethod (name, param_types);
if (rmethod != NULL)
return rmethod;
}
}
return NULL;
}
// This is a very slow implementation, since it re-scans all the