You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Torbjørn G. Dahle (Jira)" <ji...@apache.org> on 2022/04/29 11:59:00 UTC

[jira] [Created] (GROOVY-10611) Static fields not initialized when accessed from another class

Torbjørn G. Dahle created GROOVY-10611:
------------------------------------------

             Summary: Static fields not initialized when accessed from another class
                 Key: GROOVY-10611
                 URL: https://issues.apache.org/jira/browse/GROOVY-10611
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 3.0.10
            Reporter: Torbjørn G. Dahle


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.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)