[foreign-memaccess] RFR: 8253025: Add support for registering a segment with a Cleaner [v2]
Maurizio Cimadamore
mcimadamore at openjdk.java.net
Fri Sep 11 16:02:24 UTC 2020
On Fri, 11 Sep 2020 15:08:11 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Addressed review comments
>> Beefed up test
>
> test/jdk/java/foreign/TestCleaner.java line 97:
>
>> 95: enum SegmentFunction implements Function<MemorySegment, MemorySegment> {
>> 96: IDENTITY(Function.identity()),
>> 97: CLOSE(s -> { s.close(); return s; }),
>
> Won't that just skip cleaner registration, making the test redundant for that case? I guess for this case it should be
> called after registration?
Not really - note that the function is called after registration:
MemorySegment segment = makeSegment(segmentState);
// register cleaners before
for (int i = 0 ; i < n ; i++) {
segment.registerCleaner(cleanerFactory.get());
}
segment = segmentFunction.apply(segment); // <-------------------------
So, the test here is useful: it tests that the cleaner registered before close() can't really call the cleanup action
multiple times if the segment has also been closed explicitly.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/320
More information about the panama-dev
mailing list