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

Static fields not initialized when accessed from another class

    XMLWordPrintableJSON

Details

    Description

      Accessing a static field in a Groovy class from a Java class stops working when upgrading from 3.0.9 to 3.0.10.

      I originally encountered this in a Grails project, but I've managed to make this sort of minimal reproduction here: https://github.com/torbjorn-boost/groovy-static-field

      When using 3.0.9, I get this:

      13:55:15: Executing ':JavaFile.main()'...> Task :compileJava NO-SOURCE
      > Task :compileGroovy
      > Task :processResources NO-SOURCE
      > Task :classes> Task :JavaFile.main()
      GroovyFile sees 123
      JavaFile sees 123

       

      But if I bump to 3.0.10 in build.gradle, this happens:

      13:56:32: Executing ':JavaFile.main()'...> Task :compileJava NO-SOURCE
      > Task :compileGroovy
      > Task :processResources NO-SOURCE
      > Task :classes> Task :JavaFile.main()
      JavaFile sees 0

      This happens with JREs 8, 11 and 17.

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              torbjorn-boost Torbjørn G. Dahle
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: