RFR: 8330462: StringIndexOutOfBoundException when typing anything into TextField [v6]

Oliver Kopp duke at openjdk.org
Fri Apr 19 06:57:02 UTC 2024


On Thu, 18 Apr 2024 20:19:19 GMT, Oliver Kopp <duke at openjdk.org> wrote:

>> modules/javafx.graphics/src/main/java/com/sun/glass/ui/win/WinTextRangeProvider.java line 365:
>> 
>>> 363:         if (text == null) return null;
>>> 364:         validateRange(text);
>>> 365:         int endOffset = maxLength >= 0 ? Math.min(end, Math.max(start + maxLength, maxLength)) : end;
>> 
>> there is a similar code on LL 101,102,381,485
>> would we need to apply the same logic there?
>> possibly in some kind of a utility method?
>
> Done! Hopefully, not too overengineered - https://github.com/openjdk/jfx/pull/1442/files#diff-cf00c7b3f2ccd166df5df3aabcd0940072739356910a2c2107a9442aec6010dfR105
> 
> (The JDK code seems to be very compact)

I implemented it for L101, felt a bit bad and at https://github.com/openjdk/jfx/pull/1442/files/e7502d674c579667545b97ab944e82f2b093a470#diff-cf00c7b3f2ccd166df5df3aabcd0940072739356910a2c2107a9442aec6010df, Kevin also noted it could not be right there. Thus, I reverted to the original.

For the others, I used the new utility method `getValidStringIndex`

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1442#discussion_r1571915290


More information about the openjfx-dev mailing list