ComponentEvent.getComponent() may throw ClassCastException

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P3
    • 1.4.0
    • Affects Version/s: 1.3.0
    • Component/s: client-libs
    • beta2
    • generic
    • generic



      Name: ssT124754 Date: 03/01/2001


      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
      Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

      KeyEvent.setSource() takes an Object as its argument. Thus a KeyEvent's source
      is not guaranteed to be a Component and the cast in
      ComponentEvent.getComponent() may fail!

      Is that original line of code
           "return (source instanceof Component) ? (Component)source : null;"
      really so expensive that it's worth all that trouble to avoid it? Remember that
      ComponentEvent is not final and the source field (of type Object) is protected,
      not private!
      (Review ID: 117942)
      ======================================================================

            Assignee:
            Eric Hawkes (Inactive)
            Reporter:
            Shaheen Sultana (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: