[foreign-memaccess] RFR: 8253025: Add support for registering a segment with a Cleaner [v2]
Paul Sandoz
psandoz at openjdk.java.net
Fri Sep 11 16:10:00 UTC 2020
On Fri, 11 Sep 2020 15:59:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
>> 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.
Oh, doh!, i missed the code above.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/320
More information about the panama-dev
mailing list