[ http://jira.codehaus.org/browse/QDOX-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=211612#action_211612 ]
Sam Bernet commented on QDOX-201: --------------------------------- Hi Robert, I agree with your thought about the API. It seems OK to me to have an additional Constructor for {{Type}}: {code:title=Type.java|borderStyle=solid} public Type(String fullName, boolean varArgs) { this(fullName, varArgs ? 1 : 0); } {code} As shown above, internally we should just use a Type with a dimension of one, as the triple dot is in fact nothing but syntactic sugar for an Array. The Java VM itself doesn't know anything about varargs-Parameters, thus {noformat} void method(String[]) {noformat} is fully equivalent to {noformat} void method(String...) {noformat} I suggest the following: # adding above new Constructor to {{Type}} # ensuring the given Type has dimension 1 in case the varargs-Flag is set in Constructor {{JavaParameter(Type, String, boolean}}, throwing an IllegalArgumentException if not - thus returning the correct type in JavaParameter#getType() # adding overloaded method {{ModelBuilder#createType(TypeDef typeDef, boolean varargs)}}, delegating to {{ModelBuilder#createType(TypeDef typeDef, int dimensions)}}, with {{dimensions = varargs ? 1 : 0}} # changing {{ModelBuilder#addParameter(FieldDef)}} to call the new createType method if fieldDef.isVarArgs is set Forgot anything? Regards, Sam Bernet > Method Resolution incorrect for methods with vararg-parameters > -------------------------------------------------------------- > > Key: QDOX-201 > URL: http://jira.codehaus.org/browse/QDOX-201 > Project: QDox > Issue Type: Bug > Components: Java API > Affects Versions: 1.10.1 > Environment: Tested with Snapshot of QDox 1.11 from 2010-01-10 > Reporter: Sam Bernet > Attachments: TestQdoxVarArgsResolution.java > > > I suspect the method JavaParameter#getType()to give incorrect results for > vararg-parameters, resulting in JavaClass#getMethodBySignature(String, > Type[]) failing to correctly lookup existing methods. > getType() seems to just return the base type of a varargs-parameter. IMHO > opinion the correct behaviour would be to return the corresponding array-type > with dimension 1. > Example: > {noformat} > class Test { > method(String... param) {} // getType() returns Type 'String' instead of > 'String[]' > method(String param) {} // getType() returns Type 'String' as well, so > there's no way to distuingish the two methods > {noformat} > Result: > {noformat} > getMethodBySignature('method', new Type[] {new Type('String', 1)}) -> returns > null > getMethodBySignature('method', new Type[] {new Type('String')}) -> returns > first method > -> no way to retrieve second method at all?! > {noformat} > See attached test-case for a complete illustration of the problem, including > a working JUnit-Test > Best regards, > Sam Bernet -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://jira.codehaus.org/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email