-
Notifications
You must be signed in to change notification settings - Fork 32
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
method reflection does not handle overloading resolution #55
Comments
Hi jason-s, issue #44 was related to an easier way to reflect a method when there is only one method with that name defined. You can easily reflect any overloaded method using Method m = new Mirror().on(clazz).reflect().method("methodName").withArgs(Param1.class, Param2.class); Does this fix your problem? |
Nope. That assumes you know the exact classes of the declared method parameters. (e.g. as in Method.getParameterTypes) All I have is the classes of the actual arguments. (from calling Just for example, let's say you have
If your arguments are |
Ok. Now I get it. If you need the method definition, at this moment Mirror can't reflect it, but internally we have code that look for the best match method (but it probably does not follow the compile-time overloading resolution). That's probably a good point to improve according to the JLS section 15.12. Then we expose this behavior on the DSL. |
This is a major feature missing from both the Java reflection API and the present state of Mirror, IMHO, and is related to issue #44.
If you think, yeah, well, real classes don't have overloaded methods or constructors, look at java.io.File and java.io.FileInputStream.
Use case: you're running an interpreter and you want to allow dynamic method calls at runtime where the object and argument types are not known in advance.
Handling this is not easy and there are quite a few corner cases (at least if you're trying to make overloading resolution match the compile-time overloading resolution in JLS section 15.12 ).
I should be able to help w/ this (as soon as I get permission from our company's legal dept, we've done open-source contributions before so it shouldn't take too long)
The text was updated successfully, but these errors were encountered: