On Wed, 18 Oct 2023 09:57:25 GMT, Maurizio Cimadamore <mcimadam...@openjdk.org> 
wrote:

>> I'm not sure what to write to make this clearer. The address that is exposed 
>> to the native target function is indeed a temporary address that is 
>> constructed from the oop and offset. It is temporary because after the 
>> native call, the GC might move the object around, which invalidates the 
>> address.
>> 
>> This part is meant to document that native code should not be holding on to 
>> the address until after the call completes. This also includes returning the 
>> address back to Java. The address would be invalid the moment the function 
>> returns.
>> 
>> Would it help if this said: `The memory region inside the Java heap is 
>> exposed to the native target function through a temporary native address`?
>
> I'm considering to leave `As such, these temporary addresses...` out. You 
> already said that the address "is valid for the duration of the call". I'm 
> not sure the subsequent sentence adds much. If you want to make a concrete 
> example of something that should not be done, that would be better. But it 
> seems to me that the client is as in charge as this text suggests - (e.g. if 
> a native lib decides to hold onto an address, the client can't do much about 
> it).

So, summing up - either we write more and spell what are the things to be on 
the lookout for, or we leave it out.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16201#discussion_r1363595149

Reply via email to