Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Labels:None
-
Environment:Jedi 3.0.5
-
Number of attachments :
Description
Currently, one cannot construct a @SithFunctor for a method with generic argument types.
E.g., for the following method:
public Integer doMagic(final List<String> list);
I expect a @SithFunctor to look like this:
@SithFunctor(
type = LibraryClass.class, methods = @SithMethod(
name = "doMagic",
parameterTypes = { List.class }
))
This annotation leads to a "No such method" compile error.
Generic argument types cannot be specified within the annotation, because there are no class literals for generic types.
I suggest changing the code generator so that only the erasure of the types is compared. There cannot be two methods with the same signature after erasure (with some obscure corner case in the JLS where the return type seems to become part of the signature).
Additionally, I suggest adding a way to skip the parameterTypes check entirely for a given @SithMethod. A target method is then matched purely by its enclosing class and its name, with the additional check that there is only one such method.
Attached is a patch that improves the error message if a SithMethod was not found, for JDK5 and JDK6. Also, I added a check that there is only one matching method (which should not be able to be triggered as of yet, but may come in handy when my suggestion of ignoring parameter types is accepted).