<Swing Dev> [jdk17] RFR: 8268775: Password is being converted to String in AccessibleJPasswordField

Alexander Zuev kizune at openjdk.java.net
Wed Jun 23 19:34:30 UTC 2021


On Wed, 23 Jun 2021 17:50:51 GMT, Phil Race <prr at openjdk.org> wrote:

>> 8268775: Password is being converted to String in AccessibleJPasswordField
>
> src/java.desktop/share/classes/javax/swing/JPasswordField.java line 514:
> 
>> 512:         public String getAtIndex(int part, int index) {
>> 513:             if (part == AccessibleText.CHARACTER) {
>> 514:                 return getEchoString(super.getAtIndex(part, index));
> 
> I don't see how removing the local variable changes anything. Explanation ??

Here it is just a slight code cleanup. We do not need additional variable for passing value from one method to another. It serves no other purpose at all. It was used before on the second leg of the if but the usage was removed so it became useless.

> src/java.desktop/share/classes/javax/swing/JPasswordField.java line 546:
> 
>> 544:         public String getAfterIndex(int part, int index) {
>> 545:             if (part == AccessibleText.CHARACTER) {
>> 546:                 return getEchoString(super.getAfterIndex(part, index));
> 
> I don't see how removing the local variable changes anything. Explanation ??

Here it is just a slight code cleanup. We do not need additional variable for passing value from one method to another. It serves no other purpose at all.

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

PR: https://git.openjdk.java.net/jdk17/pull/127


More information about the swing-dev mailing list