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

Iterator.next() returning Object[] causes NullPointerException.

    XMLWordPrintableJSON

Details

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

    Description

      The following simple iterator:

      class bug10 implements Iterator {
      int i = 0

      Object next()

      { i++ return [ i, i*10, i*100 ] as Integer[] }

      boolean hasNext()

      { i < 5 }

      void remove() { }

      static public void main(String[] args) {
      def b = new bug10()

      b.each

      { println it }
      }
      }

      throws a NullPointerException in Closure.callViaReflection(). Oddly, calling a closure directly with an Object[] works just fine, e.g.:

      c = { println it }

      x = [3, 4, 5] as Object[]
      c

      Attachments

        Activity

          People

            phkim Kim, Pilho
            mcspanky Martin C. Martin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: