-
Notifications
You must be signed in to change notification settings - Fork 375
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
Choose the most specific method when calling overloaded methods #5
Milestone
Comments
lukaseder
added a commit
that referenced
this issue
May 29, 2014
lukaseder
added a commit
that referenced
this issue
May 29, 2014
public class JOORTests {
private static int object = 0;
private static int number = 0;
private static int integer = 0;
private static void overload(Object o) {
System.out.println("object overload invoked");
JOORTests.object++;
}
private static void overload(Number number) {
System.out.println("number overload invoked");
JOORTests.number++;
}
private static void overload(Integer integer) {
System.out.println("integer overload invoked");
JOORTests.integer++;
}
@Test
public void test() {
Reflect reflect = Reflect.onClass(JOORTests.class);
reflect.call("overload", Integer.parseInt("1"));
Assert.assertEquals(1, JOORTests.integer);
reflect.call("overload", Long.parseLong("1"));
Assert.assertEquals(1, JOORTests.number);
reflect.call("overload", "Hello world!");
Assert.assertEquals(1, JOORTests.object);
}
} This test case works fine on jdk1.8.0_271 when using |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, jOOR chooses the "first" matching method if multiple overloaded methods are applicable. E.g.:
Finding the most specific method according to the rules of the JLS is not easy, in particular because jOOR follows its own rules. E.g., in the future, we may also want to consider private methods to be eligible for the search algorithm.
The text was updated successfully, but these errors were encountered: