RFR: 8365719: Refactor uses of JLA.uncheckedNewStringNoRepl

Roger Riggs rriggs at openjdk.org
Tue Aug 19 14:14:43 UTC 2025


On Tue, 19 Aug 2025 06:00:16 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Refactor uses of JLAuncheckedNewStringNoRepl(byte[], ISO_8859_1) adding JLA.uncheckedNewStringWithLatin1Bytes(byte[]).
>> There is no decoding needed, and no exceptions expected or thrown when creating the string from the supplied latin1 bytes. 
>> If COMPACT_STRINGS is false, the bytes are inflated to UTF16.
>
> 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.

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

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


More information about the core-libs-dev mailing list