On Thu, 21 Aug 2025 13:47:03 GMT, Chen Liang <[email protected]> wrote:
>> src/java.base/share/classes/java/lang/String.java line 891:
>>
>>> 889: private static <E extends Exception> byte[] encodeWithEncoder(
>>> 890: Charset cs, byte coder, byte[] val, Class<E>
>>> characterCodingException)
>>> 891: throws E {
>>
>> This is a very curious construct; clever in a way but also a bit magical.
>> All the while enabling the caller (using null) to avoid having to declare
>> the exception.
>> If there were a concise explanation, that might be useful to future
>> maintainers.
>
> Indeed, this uses the well-known Java 8 sneaky throws trick.
Totally agreed – documented exception parametrization in 87f831e1c50.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26413#discussion_r2293730019