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

Object[] vs int[]

    XMLWordPrintableJSON

Details

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

    Description

      // This works fine.
      int[] n1 = [1, 2, 3]
      int[] n2 = [100, 200]
      def n = [n1, n2]
      n.each

      { println( it ) }


      // But, this geneates an NPE.
      Object[] n1 = [1, 2, 3]
      Object[] n2 = [100, 200]
      def n = [n1, n2]
      n.each { println( it ) }

      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
      at groovy.ui.GroovyMain.run(GroovyMain.java:267)
      at groovy.ui.GroovyMain.process(GroovyMain.java:235)
      at groovy.ui.GroovyMain.main(GroovyMain.java:138)
      at org.codehaus.groovy.tools.GroovyStarter.main(GroovyStarter.java:92)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:324)
      at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
      at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
      at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:429)
      at org.codehaus.classworlds.Launcher.main(Launcher.java:375)

      Attachments

        Issue Links

          Activity

            People

              blackdrag Jochen Theodorou
              phkim Kim, Pilho
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: