RFR: 8299807: String.newStringUTF8NoRepl and getBytesUTF8NoRepl always copy arrays
Roger Riggs
rriggs at openjdk.org
Tue Jan 17 14:56:39 UTC 2023
On Mon, 9 Jan 2023 03:34:55 GMT, Glavo <duke at openjdk.org> wrote:
> `JavaLangAccess::newStringUTF8NoRepl` and `JavaLangAccess::getBytesUTF8NoRepl` are not implemented correctly. They always copy arrays, rather than avoiding copying as much as possible as javadoc says.
>
> I ran the tier1 test without any new errors.
`newStringUTF*NoRepl` is not described or expected to optimizing the array allocation.
Nor does it mandate that callers must guarantee that the array is not re-used or modified.
The access to this method through JavaLangAccess is solely for the convenience of the algorithm.
I don't see the performance improvement as sufficient to offset the risk of mis-use and its possible loss of integrity.
-------------
PR: https://git.openjdk.org/jdk/pull/11897
More information about the core-libs-dev
mailing list