Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-97

fix toString() equals() and hashCode() for listener dynamic proxies

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.0-beta-3
    • None
    • None

    Description

      Listeners print null by default when toString() is called, which is very confusing.

      groovy> b = new javax.swing.JButton("foo")
      groovy> b.actionPerformed = { println("Found ${it}") }
      groovy> println(b.actionListeners)
      groovy>
      [null]

      when its really a dynamic proxy

      groovy> b = new javax.swing.JButton("foo")
      groovy> b.actionPerformed = { println("Found ${it}") }
      groovy> b.actionListeners.each

      { println(it.class) }

      groovy>
      class $Proxy0

      also we can't remove these listeners...

      groovy> import java.util.Arrays
      groovy> b = new javax.swing.JButton("foo")
      groovy> b.actionPerformed = { println("Found ${it}") }
      groovy> l = Arrays.asList(b.actionListeners).get(0)
      groovy> println(l)
      groovy> b.removeActionListener(l)
      groovy> b.actionListeners
      groovy>
      null
      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
      at $Proxy0.equals(Unknown Source)

      Attachments

        Activity

          People

            jstrachan James Strachan
            jstrachan James Strachan
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: