RFR: 8296024: Usage of DIrectBuffer::address should be guarded [v4]

Per Minborg pminborg at openjdk.org
Tue Nov 22 09:11:44 UTC 2022


On Mon, 21 Nov 2022 20:06:20 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>>> > Although this looks much simpler and concise, it means "a new object is created for each invocation"
>>> 
>>> My comment was actually to see if DirectBuffer could extend AutoCloseable so that the acquire returns "this" for the non-session case. Doing the equivalent for the session case might leak into MemorySessionImpl implementing DirectBuffer which you probably don't want to do. If NOP_CLOSE.close can do the Reference.reachabilityFence(this) then it would at least improve some of the use-sites.
>> 
>> Not sure that is simpler. ByteBuffer <: AutoCloseable doesn't seem to make sense to me. I'm also not sure how much object allocation (all this stuff will become value types) should be the driving factor in these code paths.
>
> Right, I didn't mean BB <: AC but to see if we avoid needing to wrap it because this PR is touching several low level and performance critical code paths. For the faraway places then having the close do a Reference.reachabilityFence(this) should avoid the surprise that the buffer has to kept alive even though it appears that the try-with-resources is doing it already.

I have reworked Acquisition. I think we could merge the old and new way in a separate PR.

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

PR: https://git.openjdk.org/jdk/pull/11260


More information about the security-dev mailing list