On 8/10/2024 4:07 am, Eric Erickson wrote:
I'm really surprised that this code does not abend or toss some kind of error, 
if the string is getting marked as released before we are done with it. I 
suppose it could be related to when the JVM actually runs the garbage 
collection that recovers the storage, but to my mind this is an error just 
waiting to happen.

Am I right? If not can someone provide clarification as to why the original 
form is correct?

It probably works because the storage still contains the original contents after it is released, and it is only "released" back to the JVM not freed. The window for it to be actually overwritten is short.

I think you are correct, but there may be another problem. GetStringUTFChars probably returns a copy of the string, but that is not guraranteed. If it is not a copy I don't think you should modify the original array. You probably want to copy it first and then perform __atoe on the destination.

--
Andrew Rowley
Black Hill Software

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to