mirror of git://gcc.gnu.org/git/gcc.git
link.cc (_Jv_Linker::resolve_method_entry): Ensure that the argument types and the return type of the found method match...
2007-03-23 Gary Benson <gbenson@redhat.com> * link.cc (_Jv_Linker::resolve_method_entry): Ensure that the argument types and the return type of the found method match those expected by the calling method. From-SVN: r123156
This commit is contained in:
parent
3c2e80433d
commit
dec93f9008
|
|
@ -1,3 +1,9 @@
|
||||||
|
2007-03-23 Gary Benson <gbenson@redhat.com>
|
||||||
|
|
||||||
|
* link.cc (_Jv_Linker::resolve_method_entry):
|
||||||
|
Ensure that the argument types and the return type of the
|
||||||
|
found method match those expected by the calling method.
|
||||||
|
|
||||||
2007-03-22 David Daney <ddaney@avtrex.com>
|
2007-03-22 David Daney <ddaney@avtrex.com>
|
||||||
|
|
||||||
PR libgcj/31228
|
PR libgcj/31228
|
||||||
|
|
|
||||||
|
|
@ -343,14 +343,6 @@ _Jv_Linker::resolve_method_entry (jclass klass, jclass &found_class,
|
||||||
|
|
||||||
|
|
||||||
end_of_method_search:
|
end_of_method_search:
|
||||||
|
|
||||||
// FIXME: if (cls->loader != klass->loader), then we
|
|
||||||
// must actually check that the types of arguments
|
|
||||||
// correspond. That is, for each argument type, and
|
|
||||||
// the return type, doing _Jv_FindClassFromSignature
|
|
||||||
// with either loader should produce the same result,
|
|
||||||
// i.e., exactly the same jclass object. JVMS 5.4.3.3
|
|
||||||
|
|
||||||
if (the_method == 0)
|
if (the_method == 0)
|
||||||
{
|
{
|
||||||
java::lang::StringBuffer *sb = new java::lang::StringBuffer();
|
java::lang::StringBuffer *sb = new java::lang::StringBuffer();
|
||||||
|
|
@ -364,6 +356,40 @@ _Jv_Linker::resolve_method_entry (jclass klass, jclass &found_class,
|
||||||
throw new java::lang::NoSuchMethodError (sb->toString());
|
throw new java::lang::NoSuchMethodError (sb->toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if (found_class->loader != klass->loader), then we
|
||||||
|
// must actually check that the types of arguments
|
||||||
|
// correspond. That is, for each argument type, and
|
||||||
|
// the return type, doing _Jv_FindClassFromSignature
|
||||||
|
// with either loader should produce the same result,
|
||||||
|
// i.e., exactly the same jclass object. JVMS 5.4.3.3
|
||||||
|
if (found_class->loader != klass->loader)
|
||||||
|
{
|
||||||
|
JArray<jclass> *found_args, *klass_args;
|
||||||
|
jclass found_return, klass_return;
|
||||||
|
|
||||||
|
_Jv_GetTypesFromSignature (the_method,
|
||||||
|
found_class,
|
||||||
|
&found_args,
|
||||||
|
&found_return);
|
||||||
|
_Jv_GetTypesFromSignature (the_method,
|
||||||
|
klass,
|
||||||
|
&klass_args,
|
||||||
|
&klass_return);
|
||||||
|
|
||||||
|
jclass *found_arg = elements (found_args);
|
||||||
|
jclass *klass_arg = elements (klass_args);
|
||||||
|
|
||||||
|
for (int i = 0; i < found_args->length; i++)
|
||||||
|
{
|
||||||
|
if (*(found_arg++) != *(klass_arg++))
|
||||||
|
throw new java::lang::LinkageError (JvNewStringLatin1
|
||||||
|
("argument type mismatch with different loaders"));
|
||||||
|
}
|
||||||
|
if (found_return != klass_return)
|
||||||
|
throw new java::lang::LinkageError (JvNewStringLatin1
|
||||||
|
("return type mismatch with different loaders"));
|
||||||
|
}
|
||||||
|
|
||||||
return the_method;
|
return the_method;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue