[foreign-memaccess] RFR: 8253243: Investigate ways to make MemorySegment::ofNativeRestricted more composable [v2]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Wed Sep 16 17:32:10 UTC 2020


On Wed, 16 Sep 2020 16:32:29 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Address review comments
>
> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java line 341:
> 
>> 339:                     try {
>> 340:                         runnable.run();
>> 341:                     } catch (Throwable t) {
> 
> Maybe the exception should be re-thrown after doing critical cleanup?

We could do that - but I'd prefer to leave this as is.

> test/jdk/java/foreign/TestNoForeignUnsafeOverride.java line 43:
> 
>> 41:     @Test(expectedExceptions = IllegalAccessError.class)
>> 42:     public void testUnsafeAccess() {
>> 43:         MemorySegment.ofNativeRestricted();
> 
> Should be:
> Suggestion:
> 
>         MemoryAddress.ofLong(42).asSegmentRestricted(10);
> Right? To retain the same behaviour?

This test is, if I understand correctly, simply testing that you can't calla restricted method if the JDK property has
not been set on the command line. It's not important WHICH restricted method is called. At the time the test was
written we didn't have the more succint ofNativeRestricted - now we do, so I thought to just use that, for brevity.

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

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


More information about the panama-dev mailing list