You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/12/11 16:12:00 UTC

[jira] [Issue Comment Deleted] (GROOVY-9332) Error occurred when accessing static field in lambda within static initialization block

     [ https://issues.apache.org/jira/browse/GROOVY-9332?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Eric Milles updated GROOVY-9332:
--------------------------------
    Comment: was deleted

(was: After VariableExpressionTransformer turns "staticField" into "this.staticField", something makes it "Type.staticField", similar to what you are adding to VariableExpressionTransformer.  We may be missing a bit of metadata that allows that last transformation before AsmClassGenerator generates instructions.)

> Error occurred when accessing static field in lambda within static initialization block
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9332
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9332
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Daniel Sun
>            Priority: Major
>             Fix For: 3.0.0-rc-3
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The following test failed due to accessing static field {{one}} 
> {code:java}
> @groovy.transform.CompileStatic
> class Test1 {
>     static sl
>     static int one = 1
>     static { sl = [1, 2, 3].stream().map(e -> e + one).toList() }
> }
> assert [2, 3, 4] == Test1.sl
> {code}
> {code:java}
> java.lang.ExceptionInInitializerError
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at ConsoleScript2.run(ConsoleScript2:8)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> Caused by: java.lang.ClassCastException: class Test1$__clinit__lambda1 cannot be cast to class Test1 (Test1$__clinit__lambda1 and Test1 are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @f055fc9)
> 	at Test1$__clinit__lambda1.doCall(ConsoleScript2:5)
> 	at Test1.<clinit>(ConsoleScript2:5)
> 	... 7 more
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)