[foreign-preview] RFR: 8282626: Revert semantic of session accessors [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Mar 7 10:18:24 UTC 2022


On Fri, 4 Mar 2022 18:27:25 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> If we need to restrict more (e.g. have session views which don't support anything, like allocation, or close action), we might add another "unmodifiable" view - but doing so would at least require another method in `MemorySegment` and `VaList` to "rebase" the resources onto a new unmodifiable session (since it would not be possible to create resources in the unmodifiable session to begin with!).

A slightly simpler way to do this, would be to provide some method in `MemorySegment` which would return another `MemorySegment` whose `session` accessor throws (or make the method return `Optional`). This will effectively give a memory segment that cannot be used to go back at the session capabilities, and therefore cannot be used to close, allocate, or add cleanup actions.

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

PR: https://git.openjdk.java.net/panama-foreign/pull/661


More information about the panama-dev mailing list