-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[LANG-1597][LANG-1782] Fix getMatchingAccessibleMethod when no varargs are supplied and when the supplied varargs don't match the exact class #1427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…s are supplied and when the supplied varargs don't match the exact class The current implementation discarded methods which could be potential matches because the matching was way to strict. This change loosens the check to allow any assignable values. The change also checks all variable arguments instead of just the last argument. To facilitate various number types and conversion NumberUtils.convertIfNotNarrowing was also introduced. This allows integers to be passed to methods which take Long... varargs
16190be
to
6ac0dea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @joeferner
Thank you for your updates. Please rebase on git master and see my comments.
* value</li> | ||
* </ul> | ||
*/ | ||
public static <T extends Number> T convertIfNotNarrowing(Number number, Class<T> targetType) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep all of this package-private in the .reflect
package.
} | ||
|
||
// Perform conversion | ||
if (targetType == Byte.class) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about char
primitives?
/** | ||
* Returns a numeric rank for the specified number type to determine | ||
* its position in the widening conversion hierarchy. | ||
* <p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll want to link to the JLS to show canonical definitions.
@@ -994,6 +1012,16 @@ void testInvokeJavaVarargsOverloadingResolution() throws Exception { | |||
(Object[]) ArrayUtils.EMPTY_CLASS_ARRAY)); | |||
} | |||
|
|||
@Test | |||
void testInvokeJavaVarargsResolution() throws Exception { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this cover all of the getRank()
cases?
What about char
?
Fixes LANG-1597 and LANG-1782
The current implementation discarded methods which could be potential matches because the matching was way to strict. This change loosens the check to allow any assignable values. The change also checks all variable arguments instead of just the last argument.
To facilitate various number types and conversion
NumberUtils.convertIfNotNarrowing was also introduced. This allows integers to be passed to methods which take Long... varargs