groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xiaoguang Wang (JIRA)" <j...@apache.org>
Subject [jira] [Created] (GROOVY-8764) Closure inside an anonymous class uses wrong parent class instance
Date Wed, 22 Aug 2018 18:27:00 GMT
Xiaoguang Wang created GROOVY-8764:
--------------------------------------

             Summary: Closure inside an anonymous class uses wrong parent class instance
                 Key: GROOVY-8764
                 URL: https://issues.apache.org/jira/browse/GROOVY-8764
             Project: Groovy
          Issue Type: Bug
          Components: Static compilation
    Affects Versions: 2.5.2
            Reporter: Xiaoguang Wang


This bug only occurs with @ComplieStatic

 
{code:java}
@CompileStatic
class GroovyTest {

    private String foo

    void test() {
        new Runnable() {
            void run() {
                def c = {
                    foo
                }
                c()
            }
        } .run()
    }

    static void main(String ...args) {
        new GroovyTest().test()
    }
}
{code}
Crash:
{code:java}
Exception in thread "main" java.lang.ClassCastException: com.test.spring4mvc.controller.GroovyTest$1
cannot be cast to com.test.spring4mvc.controller.GroovyTest
    at com.test.spring4mvc.controller.GroovyTest$1$_run_closure1.doCall(GroovyTest.groovy)
    at com.test.spring4mvc.controller.GroovyTest$1$_run_closure1.call(GroovyTest.groovy)
    at com.test.spring4mvc.controller.GroovyTest$1.run(GroovyTest.groovy:16)
    at com.test.spring4mvc.controller.GroovyTest.test(GroovyTest.groovy:11)
    at com.test.spring4mvc.controller.GroovyTest.main(GroovyTest.groovy:22)
{code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message