Groovy
  1. Groovy
  2. GROOVY-4386

static import does not work in Groovy 1.7.4

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.4
    • Fix Version/s: 1.7.6, 1.8-beta-3
    • Component/s: None
    • Labels:
      None
    • Environment:
      Windows, Groovy Version: 1.7.4 JVM: 1.6.0_21

      Description

      Static import does not work from Groovy scripts.

      Example:

      foo/Constants.groovy:

      package foo
      
      class Constants {
          static final PI = 3.14
      }
      

      foo/Test.groovy

      package foo
      import static foo.Constants.PI
      
      class Test {
          static main(args) {
              println("pi=" + PI)
          }
      }
      

      When you try to run this (without compling with groovyc first), you get:

      groovy -cp . foo\Test.groovy
      Caught: groovy.lang.MissingPropertyException: No such property: PI for class: foo.Test
              at foo.Test.main(Test.groovy:6)
      

      If you first run "groovyc foo\Constants.groovy" the above command succeeds.

      1. p1.patch
        1 kB
        Jochen Theodorou
      2. p2.patch
        1 kB
        Jochen Theodorou

        Activity

        Frode Stokke created issue -
        Jochen Theodorou made changes -
        Field Original Value New Value
        Assignee Paul King [ paulk_asert ]
        Jochen Theodorou made changes -
        Attachment p1.patch [ 52659 ]
        Jochen Theodorou made changes -
        Attachment p2.patch [ 52660 ]
        Paul King made changes -
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 1.8-beta-3 [ 16750 ]
        Fix Version/s 1.7.6 [ 16749 ]
        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 [ 12733325 ] Default workflow, editable Closed status [ 12745147 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12967790 ] Default workflow, editable Closed status [ 12975537 ]
        Mark Thomas made changes -
        Assignee paulk_asert [ paulk_asert ] Paul King [ paulk ]

          People

          • Assignee:
            Paul King
            Reporter:
            Frode Stokke
          • Votes:
            15 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development