> `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 ------------- Changes: - all: https://git.openjdk.org/jdk/pull/33049/files - new: https://git.openjdk.org/jdk/pull/33049/files/fad7520c..afc1537b Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=33049&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=33049&range=00-01 Stats: 5 lines in 1 file changed: 2 ins; 1 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/33049.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/33049/head:pull/33049 PR: https://git.openjdk.org/jdk/pull/33049
