RFR: 8354646: java.awt.TextField allows to identify the spaces in a password when double clicked at the starting and end of the text [v11]

Prasanta Sadhukhan psadhukhan at openjdk.org
Fri Jun 6 07:41:54 UTC 2025


On Fri, 6 Jun 2025 07:28:37 GMT, Jeremy Wood <duke at openjdk.org> wrote:

>> Make sure AquaTextPasswordFieldUI can't use selectWordAction.
>> 
>> The core problem here was we could call selectWordAction in the Aqua LAF on a JPasswordField. This problem was already solved in the BasicPasswordFieldUI and SynthPasswordFieldUI, but the AquaTextPasswordFieldUI does NOT extend the BasicPasswordFieldUI, so it wasn't inheriting this solution.
>> 
>> So the problem is partially about multiple inheritance.
>> 
>> My first response at solving the problem is just to move the existing solution to the parent BasicTextUI class and use an instanceof to make sure it is only applied to JPasswordFields.
>> 
>> There may be many different philosophies/recommendations on how to resolve this; I'm open to suggestions.
>
> Jeremy Wood has updated the pull request incrementally with one additional commit since the last revision:
> 
>   8354646: update SetEchoCharWordOpsTest to refer to 8354646
>   
>   This is in response to:
>   https://github.com/openjdk/jdk/pull/25443#discussion_r2131645722

test/jdk/javax/swing/plaf/basic/BasicPasswordFieldUI/PasswordSelectionWordTest.java line 64:

> 62:             e.printStackTrace();
> 63:             return false;
> 64:         } catch (RuntimeException e) {

guess this catch block is not needed

test/jdk/javax/swing/plaf/basic/BasicPasswordFieldUI/PasswordSelectionWordTest.java line 94:

> 92:         if (selectionStart != 0 || selectionEnd != str.length()) {
> 93:             throw new Error("selectionStart = " + selectionStart +
> 94:                     " and selectionEnd = " + selectionEnd);

please change to RuntimeException to make it consistent with other tests

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25443#discussion_r2131680454
PR Review Comment: https://git.openjdk.org/jdk/pull/25443#discussion_r2131681790


More information about the client-libs-dev mailing list