[foreign-memaccess+abi] RFR: 8303667: Drop MemoryLayout::valueLayout factory

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Mar 6 14:52:54 UTC 2023


We have been thinking more about how the layout API might be affected by Valhalla specialized types. With Valhalla, it might be possible to, eventually, get rid of hand-specialized classes such as `ValueLayout.OfInt` and friends, and replace them either with `ValueLayout<int>`, or some `ScalarLayout<int>` (where `ScalarLayout<X> extends ValueLayout`). This would allow us to, also eventually, only provide _one_ accessor for all value/scalar layouts in `MemorySegment`.

Under this migration scenario, having a toplevel factory such as `MemoryLayout::valueLayout`, whose semantics is strictly defined in terms of the hand-specialzied classes doesn't seem a great idea.

Since this factory is only used rarely (mostly in tests - we could not find any usage in existing GitHub projects targeting the FFM API), it would be better to remove it, to avoid having to deal with pesky migration issues later. 

Of course, if you are aware of cases we missed where the factory is used in the wild, please let us know. (Although, in general, it is not too difficult to re-iimplement a similar method using the `ValueLayout` constants - `jextract` will need to do this, for instance).

-------------

Commit messages:
 - Initial push

Changes: https://git.openjdk.org/panama-foreign/pull/810/files
 Webrev: https://webrevs.openjdk.org/?repo=panama-foreign&pr=810&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8303667
  Stats: 149 lines in 7 files changed: 51 ins; 95 del; 3 mod
  Patch: https://git.openjdk.org/panama-foreign/pull/810.diff
  Fetch: git fetch https://git.openjdk.org/panama-foreign pull/810/head:pull/810

PR: https://git.openjdk.org/panama-foreign/pull/810


More information about the panama-dev mailing list