[foreign-memaccess] RFR 8235259: Java layout constants should use native endianness

John Rose john.r.rose at oracle.com
Tue Dec 3 18:49:48 UTC 2019


On Dec 3, 2019, at 10:41 AM, Paul Sandoz <paul.sandoz at oracle.com> wrote:
> 
> And one could use say Integer.LAYOUT.withOrder(ByteOrder.BIG_ENDIAN) for interop purposes.


There has to be a fool-proof way to get this functionality.  My nightmare
scenario is somebody developing a Panama app. only on x86, that talks to
little-endian packets or disk files, and it breaks badly the first time it runs
on a PPC or SPARC .  (Or developed on SPARC and talking to big-endian
RPC packets, etc.)

It’s a balancing act between being friendly to internal layouts and to
external ones.  There’s no way to do both at once (except being in denial
in the short term, but that ends poorly).

I have argued in the past that external layouts should be favored, on the
grounds that a layout should mean the same thing everywhere (WORA
for layouts).  I accept that the actual usage-in-anger must determine where
we tilt the balance.  Please, just make sure there’s a best-practices story
for getting WORA (easily!) when you need it.  Probably an import static
idiom is sufficient.

— John


More information about the panama-dev mailing list