Question About MethodHandles.findSpecial
Fredrik Öhrström
fredrik.ohrstrom at oracle.com
Wed May 6 04:03:52 PDT 2009
John Rose skrev:
> It would let you emulate the super(...) call in a language which needs
> to make a subclass of some Java class with a non-trivial constructor,
> without forcing the language to generate bytecodes for that subclass's
> constructor call.
When I think a little bit more about this, if you want to call a
constructor through a method handle, you will have to use the
uninitialized referenced (which is a reference created with new but no
constructor has executed on it yet) as an argument to the invokevirtual
call. The bytecode verifier will prohibit this. Both in a plain method
and in a constructor.
The bytecode verifier also prohibits calling a constructor on an already
initialized reference. With a MethodHandle to a constructor it would be
possible violate this restriction. I am not sure this is a good idea.
//Fredrik
More information about the mlvm-dev
mailing list