[foreign-memaccess] RFR: 8240874: Add finer-grained access control for memory segments
Jorn Vernee
jvernee at openjdk.java.net
Thu Mar 12 14:43:06 UTC 2020
On Wed, 11 Mar 2020 13:25:54 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This patch adds a finer-grained access control for memory segments; instead of the ad-hoc `MemorySegment::asReadOnly`,
> we now support a more complete `MemorySegment::withAccessModes`, where access modes is an int mask.
> Supported access modes are `READ`, `WRITE`, `CLOSE` and `ACQUIRE`, which gives much more freedom to clients when it
> comes to create restricted views (I've added a new section on that in the MemorySegment toplevel javadoc).
> I also did some minor changes, mostly to get rid of confinement restrictions where such restrictions were not needed
> (e.g. `MemorySegment::asSlice`).
test/jdk/java/foreign/TestSegments.java line 244:
> 243: int nActions = AccessActions.values().length;
> 244: Object[][] results = new Object[nActions * nActions][];
> 245: for (int accessModes = 0 ; accessModes < results.length ; accessModes++) {
I think this should be:
Suggestion:
Object[][] results = new Object[1 << nActions][];
Since the number of combinations is 2^4. Though for 4 access modes 4 * 4 and 1 << 4 are both 16, it becomes a problem
if we add or remove access modes.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/45
More information about the panama-dev
mailing list