4 ms·
Aren't methods already an object of class java.lang.reflect.Method? Do you mean you should be able to do something like foo(PrintStream.println.method) like yo
by rukkyg 15y ago
Aren't methods already an object of class java.lang.reflect.Method? Do you mean you should be able to do something like foo(PrintStream.println.method) like you can do foo(PrintStream.class)?
- eternalban 15y agoNo, a class's methods are not instances of java.lang.reflect.Method. The latter is simply a 'reflection', per the package name, of first class JVM construct e.g. a reflection on a method.
- riffraff 15y agowould you care to explain why this is not enough? You can pass them around, invoke them, get their properties. The interface may be bad but I'm not sure what is missing.
- eternalban 15y agoIn the original comment, I was merely addressing the misunderstanding of the GP regarding the reflection packages constructs. The interface is your basic (irreducible) disconnected/unbound procedure invocation API, with all the positive/warts associated. I agree that in principle, we have enough information in the reflection data structure to allow a (specific) JVM implementation to provide a non-standard 'method object' feature. Consensus, possibly? (Good question, really. C. Nutter is one to hit with that one.)