Menu

#36 FastClass.getMethod() fails

open
nobody
None
5
2011-11-30
2011-11-30
No

Consider this code:

public class MyClass
{
:
:
:
public MyClass clone()
{
return new MyClass(this) ;
}
}

FastClass.getMethod() will most probably fail to generate a FastMethod for this method because the DuplicatePredicate used in FastClassEmitter does not weed out the "protected Object clone()" of Object class from the methods list. That happens because the DuplicatePredicate depends on MethodWrapper which uses the return type of the method when generating the key.

The solution for DuplicatePredicate filter is to use an alternate MethodWrapper that ignores the return type. That way the descendant classes' methods will always get priority which is the expected behavior for method invocation anyway.

Discussion