Groovy
  1. Groovy
  2. GROOVY-3311

NPE on Groovy 1.6-RC2: Cannot invoke method times() on null object

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 1.6-beta-2, 1.6-rc-1, 1.6-rc-2
    • Fix Version/s: 1.6-rc-3, 1.6.1, 1.7-beta-1
    • Component/s: None
    • Labels:
      None

      Description

      The following code breaks Groovy 1.6 with NPE, while passes fine on Groovy 1.5.7:

      [code]
      --------- test.gr --------------
      public class Day extends Date {

      static sdf = new java.text.SimpleDateFormat("dd.MM.yyyy")

      public static Day get(_date)

      { return new Day(sdf.parse(_date)) }

      def hours = []

      public Day(Date _date) {
      super(_date.time)
      def time = getTime()
      24.times

      { hour -> hours << new Date(time + hour*1000*60*60) }

      }

      public String toString()

      { sdf.format(this) }

      static def period = (1..3).toList().collect { get "1$

      {it}

      .11.2007" }
      }

      println new Day(new Date())
      --------------------------------
      [/code]

      >> groovy-1.6-RC2/bin/groovy test.gr
      [code]
      Caught: java.lang.ExceptionInInitializerError
      java.lang.ExceptionInInitializerError
      at java.lang.Class.forName0(Native Method)
      at java.lang.Class.forName(Class.java:169)
      . . .
      Caused by: java.lang.NullPointerException: Cannot invoke method times() on null object
      at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
      at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:743)
      at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:720)
      at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:17)
      at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:43)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:124)
      at Day.<init>(test.gr:14)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      . . .
      [/code]

        Activity

        Mark Thomas made changes -
        Workflow jira [ 12973591 ] Default workflow, editable Closed status [ 12980725 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12732307 ] Default workflow, editable Closed status [ 12744103 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Roshan Dawrani made changes -
        Fix Version/s 1.6 [ 14913 ]
        Roshan Dawrani made changes -
        Fix Version/s 1.7-beta-1 [ 14014 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.6 [ 14913 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.6.1 [ 14852 ]
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        Jochen Theodorou made changes -
        Field Original Value New Value
        Priority Major [ 3 ] Critical [ 2 ]
        Fix Version/s 1.6 [ 14913 ]
        Alexander Kleymenov created issue -

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Alexander Kleymenov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development