On 4/30/19 6:43 AM, Ivan Gerasimov wrote:
I used StringConcatHelper.newArray() to avoid bringing Unsafe into StringLatin1. In the StringLatin1.replace(), the newly allocated array is guaranteed to be filled up, and the filling code should never throw, so I believe using uninitialized arrays here is justified.

...even if it throwed (and throwing in the middle could be provoked with for example Thread.stop), the allocated array would not escape the function. So the method just has to guarantee that when it returns normally, all bytes of array have been overwritten and that the array is published securely (i.e. assigned to a final field of an object who's reference is returned from the method)...

Peter

Reply via email to