On Fri, 25 Sep 2026 01:35:08 GMT, Prasanta Sadhukhan <[email protected]> 
wrote:

>> `View.getNextVisualPositionFrom `could throw a NullPointerException when 
>> asked to navigate NORTH or SOUTH while the view has no JTextComponent 
>> container
>> 
>> Although the method initially handled a null container before retrieving the 
>> caret, 
>> it later dereferenced the same container calling `modelToView` and passed it 
>> to vertical-navigation methods `getPositionAbove`/`getPositionBelow `causing 
>> NPE.
>> 
>> The fix verifies that the container is a JTextComponent before performing 
>> vertical navigation. If no suitable text component is available, the method 
>> returns -1 (since -1 is already established as “not computable/no visual 
>> position” as per the `Utilities.getPositionAbove/Below `spec)
>> https://github.com/openjdk/jdk/blob/2365ecc5fd83cf27c6c55aaca5aa6bad6ae9dbbf/src/java.desktop/share/classes/javax/swing/text/Utilities.java#L748-L749
>> indicating that the next visual position cannot be computed. The fix also 
>> avoids a potential ClassCastException when the container is not a text 
>> component.
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Prasanta Sadhukhan has updated the pull request incrementally with one 
> additional commit since the last revision:
> 
>   Test update

Marked as reviewed by prr (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/33049#pullrequestreview-5344858117

Reply via email to