On Fri, 22 Aug 2025 14:25:19 GMT, Roger Riggs <rri...@openjdk.org> wrote:

>> Volkan Yazici has updated the pull request incrementally with five 
>> additional commits since the last revision:
>> 
>>  - Renamed to `malformedASCII`
>>  - Improve exception parametrization
>>  - Document parametrization on the exception type
>>  - Avoid using links in the Javadoc title line
>>  - Rename `NoReplTest` and fix its copyright year
>
> src/java.base/share/classes/java/lang/String.java line 1316:
> 
>> 1314: 
>> 1315:     @SuppressWarnings("unchecked")
>> 1316:     private static <E extends Exception> E malformedInputException(int 
>> off, int nb, Class<E> exceptionClass) {
> 
> The argument name can be "_", since it is ignored and is unused in the body.
> Comment the method as always throwing MalformedInputException.
> Similarly in the other malformedInput methods*.

I've removed the need to pass a `Class<E>` to these exception factories, and 
improved their documentation in 584e6e213ec.

> The argument name can be "_", since it is ignored and is unused in the body.

For the record, AFAIK, this is not possible for method arguments. Quoting [ยง6.1 
(Names > 
Declarations)](https://docs.oracle.com/javase/specs/jls/se24/html/jls-6.html#jls-6.1):

> If a declaration does not include an identifier, but instead includes the 
> keyword _ (underscore), then the entity cannot be referred to by name. The 
> following kinds of entity may be declared using an underscore:
>
> * A local variable, one of the following: ...
> * An exception parameter of an exception handler declared in a catch clause 
> of a try statement
> * A formal parameter of a lambda expression

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26413#discussion_r2297377015

Reply via email to