RFR: 8365719: Refactor uses of JLA.uncheckedNewStringNoRepl

Chen Liang liach at openjdk.org
Tue Aug 19 15:26:38 UTC 2025


On Tue, 19 Aug 2025 14:11:29 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

>> src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java line 330:
>> 
>>> 328:      * @return the newly created string
>>> 329:      */
>>> 330:     String uncheckedNewStringWithLatin1Bytes(byte[] bytes);
>> 
>> @RogerRiggs, we introduce a new `JLA::uncheckedNewStringNoRepl` specialization that
>>  doesn't throw `CCE` and fix the charset to Latin-1. _"The only reason"_ we do this is to save the call-site from catching `CCE`, am I right?
>
> The common case is that the caller already has created a latin1 string, and it avoids the overhead of re-dispatching on the Charset and adding decoding overhead. 
> The rationale for adding the package busting access is to improve performance, both in avoiding an unnecessary allocation and compute cycles.  The callers in each of these cases have been tuned for high performance.

Using `uncheckedNewStringNoRepl` for the performance side effect is confusing, especially with the meaningless try-catch and the constant encoding. A dedicated API allows us to track this particular usage better.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26831#discussion_r2285613575


More information about the core-libs-dev mailing list