Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8302511

HitInfo.toString() throws IllegalArgumentException

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • jfx21
    • jfx21
    • javafx
    • b24

      toString() methods should not throw an exception under any circumstances (I think it is when the (x,y) coordinates are outside of the Text bounds). The second invocation of toString on the same instance does not cause NPE, and the insertionIndex field gets set in getInsertionIndex() just before the exception is thrown - so not only we have an exception, but also the object might enter an inconsistent/incorrect state.

      This may be a sign of a larger issue, but at least toString() should print N/A if HitInfo.getInsertionIndex() throws an exception.

      ```
      Exception in thread "JavaFX Application Thread" java.lang.IllegalArgumentException: offset out of bounds
      at java.base/sun.text.RuleBasedBreakIterator.checkOffset(RuleBasedBreakIterator.java:730)
      at java.base/sun.text.RuleBasedBreakIterator.following(RuleBasedBreakIterator.java:744)
      at javafx.graphics/javafx.scene.text.HitInfo.getInsertionIndex(HitInfo.java:84)
      at javafx.graphics/javafx.scene.text.HitInfo.toString(HitInfo.java:100)
      at java.base/java.lang.String.valueOf(String.java:4225)
      at java.base/java.lang.StringBuilder.append(StringBuilder.java:173)
      at andy_test/goryachev.rich.RichTextAreaBehavior.nextCharacterVisually_textArea(RichTextAreaBehavior.java:506)
      at andy_test/goryachev.rich.RichTextAreaBehavior.nextCharacterVisually(RichTextAreaBehavior.java:389)
      at andy_test/goryachev.rich.RichTextAreaBehavior.moveLeft(RichTextAreaBehavior.java:316)
      at andy_test/goryachev.rich.RichTextAreaBehavior.handleKeyEvent(RichTextAreaBehavior.java:151)
      at javafx.base/com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:247)
      at javafx.base/com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
      at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:232)
      at javafx.base/com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:189)
      at javafx.base/com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
      at javafx.base/com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
      at javafx.base/com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
      ```

            angorya Andy Goryachev
            angorya Andy Goryachev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: