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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0-JSR-2
    • Fix Version/s: 1.0-JSR-3
    • Component/s: None
    • Labels:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: