RFR: 8295044: Implementation of Foreign Function and Memory API (Second Preview) [v27]
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Nov 16 16:16:21 UTC 2022
On Wed, 16 Nov 2022 16:01:52 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix typo in SegmentScope javadoc
>
> src/java.base/share/classes/java/lang/foreign/Arena.java line 132:
>
>> 130: * and all the memory segments associated with it can no longer be accessed. Furthermore, any off-heap region of memory backing the
>> 131: * segments associated with that scope are also released.
>> 132: * @throws IllegalStateException if the arena has already been {@linkplain #close() closed}.
>
> It's not wrong to specify that close throw if already closed but it goes against the advice in AutoCloseable to try to have close methods be idempotent. There may be a good reason for this but I can't help wondering if there are error cases when wrapping that might lead to close being called more than once.
In our experience with using the API, having exceptions when something is funny about close is very valuable info (as also stated in the javadoc). Almost always there's a subtle temporal bug going on which the ISE catches. I'm not sure if here you refer to the fact that the javadoc is being overly broad in saying "already been closed" instead of "already been closed _successfully_" ? What kind of problems are you thinking of?
-------------
PR: https://git.openjdk.org/jdk/pull/10872
More information about the hotspot-dev
mailing list