Groovy
  1. Groovy
  2. GROOVY-4471

NPE in property access in anonymous inner classes

    Details

      Description

      class X {
          private A a = new A()
          public B b
          public X() {
              b = new B() {
                  public String getFoo() {a}
              }
          }
      }
      
      class A {}
      class B {
          B(){getFoo()}
          def getFoo(){}
      }
      
      def x = new X()
      

      The code above fails with

      Caught: java.lang.NullPointerException
      	at X$1.propertyMissing(TryGroovy.groovy)
      	at X$1.getFoo(TryGroovy.groovy:6)
      	at X$1.getFoo(TryGroovy.groovy)
      	at B.<init>(TryGroovy.groovy:13)
      	at X$1.<init>(TryGroovy.groovy)
      	at X.<init>(TryGroovy.groovy:5)
      	at TryGroovy.run(TryGroovy.groovy:16)
      

        Activity

        Roshan Dawrani created issue -
        Cédric Champeau made changes -
        Field Original Value New Value
        Assignee Jochen Theodorou [ blackdrag ] Cedric Champeau [ melix ]
        Hide
        Cédric Champeau added a comment -

        Fixed in master and 1.8.x branch. However, I'm not closing it since backporting to 1.7.x is still under discussion.

        Show
        Cédric Champeau added a comment - Fixed in master and 1.8.x branch. However, I'm not closing it since backporting to 1.7.x is still under discussion.
        Cédric Champeau made changes -
        Fix Version/s 1.8.4 [ 17852 ]
        Fix Version/s 1.7.11 [ 17244 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.9-beta-4 [ 17656 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Mark Thomas made changes -
        Workflow jira [ 12733407 ] Default workflow, editable Closed status [ 12745212 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12970979 ] Default workflow, editable Closed status [ 12978750 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        365d 16h 8m 1 Cédric Champeau 12/Oct/11 04:36
        Resolved Resolved Closed Closed
        1d 20h 51m 1 Paul King 14/Oct/11 01:28

          People

          • Assignee:
            Cédric Champeau
            Reporter:
            Roshan Dawrani
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development