Question About MethodHandles.findSpecial

Rémi Forax forax at univ-mlv.fr
Tue May 5 10:18:28 PDT 2009


Hi frederik,

Tobias Ivarsson a écrit :
> On Tue, May 5, 2009 at 5:15 PM, Fredrik Öhrström 
> <fredrik.ohrstrom at oracle.com <mailto:fredrik.ohrstrom at oracle.com>> wrote:
>
>     What is the purpose of being able to invoke the constructor
>     through a MethodHandle? 
>

In my opinion: avoid late binding.

>     The reason I am asking is because
>     to me, it seems like we cannot perform a new through
>     a MethodHandle. Which means that we have to generate a
>     factory method (to which we can bind a MethodHandle) to
>     create a new instance and then we can just as well put
>     the call to the constructor there. Or am i missing
>     something? :-)
>
>
> Isn't findSpecial just using the same semantics as invokespecial?  
> i.e. invoking/finding the method on the exact class instead of doing a 
> virtual dispatch. That is used for other things than only 
> constructors, in Java this is used for super.method(..)-invocations.
or invocation of private methods, see section 7.7 of the JVM spec.

>
> /Tobias
Rémi



More information about the mlvm-dev mailing list