On Thu, 24 Sep 2026 06:21:44 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). This pull request has now been integrated. Changeset: 93bfd596 Author: Prasanta Sadhukhan <[email protected]> URL: https://git.openjdk.org/jdk/commit/93bfd596427c2c40f0c1da09d4397e2aed18b4fe Stats: 78 lines in 2 files changed: 75 ins; 0 del; 3 mod 8391985: View.getNextVisualPositionFrom can throw NullPointerException Reviewed-by: prr, jdv ------------- PR: https://git.openjdk.org/jdk/pull/33049
