Function types versus arrays

John Rose John.Rose at Sun.COM
Fri Feb 12 14:46:17 PST 2010


On Feb 12, 2010, at 2:20 PM, Alex Buckley wrote:

> But can you show me how an array of MethodHandles performs dynamic 
> typechecking at array store?

Yes, that's the problem; there's no way at present to tag a MethodHandle[] array with the extra typing information (the static information which was erased).

The root problem is that, while it is easy to reify and runtime-check the static function type (say, as a java.dyn.MethodType), it is an unsolved problem to put such extra type info on an array.  (It can be done on a list with a wrapper, since lists are fully abstract.  But arrays are not.)

The best way I know of to tag function arrays is to define function arrays as pseudo-arrays which work at runtime like a Collections.checkedList but look at the source level like arrays.  The most surprising wrinkle of such a design, IMO, is that they would fail to be subtypes of Object[], much like int[] fails today.

-- John


More information about the lambda-dev mailing list