Binding a single function symbol with [foreign]

Jorn Vernee jbvernee at
Thu Sep 6 23:41:07 UTC 2018

> The way it works now is that a native type, modeled by a LayoutType
> abstraction is the fusion of two elements:
> * a layout - which tells you how many bits there are in that memory 
> region
> * a Java carrier - the Java type you want to view those bits as
> So, assuming you have a u64:i8, e.g. a pointer to a signed 8 bit, it's
> really up to the Java client whether to model that as Pointer<Byte>,
> Pointer<Short>, Pointer<Integer>, Pointer<Long>. The layout info and
> the carrier info attached to a memory region are, up to a degree,
> orthogonal.

Ah I see! I had been reading through your binder v3 document [1] but how 
Layout, LayoutType and Java Carrier types fitted together hadn't fully 
'clicked' yet, but now I have good picture :)

> That said, if you want to generate a method handle out of a native
> function, a method handle has a type, so it seems fair that the user
> provides the type it wants for the call. Of course there could be
> (maybe) an override which infers everything automatically (if it can),
> but the most complete version would always be the carrier + layout
> one.

Yes, understanding all of the above I can see that passing some kind of 
method type for the Java side is pretty much always necessary to signal 
which carrier types you want to use.

> I think these are all good ideas - not sure if we are far along the
> road to start exploring them, as our priority in the short term is in
> stabilizing what we've got ahead of an early access release. But what
> you propose looks sensible, and things that programmers might indeed
> want to do.
> Thanks
> Maurizio

Thanks for the info!


More information about the panama-dev mailing list