[ 
https://issues.apache.org/jira/browse/GROOVY-9332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16993717#comment-16993717
 ] 

Eric Milles edited comment on GROOVY-9332 at 12/11/19 5:25 PM:
---------------------------------------------------------------

I restored the true return for WriterController#isInClosure for lambdas.  The 
test case mentioned in the description works correctly now.  The additional 
test case for static property += is throwing NPE.  I will try to see why this 
is.  Your proposed change to VariableExpressionTransformer or some kind of 
change in classgen may still be required.


was (Author: emilles):
I restored the true return for WriterController#isInClosure for lambdas.  The 
test case mentioned in the description works correctly now.  The additional 
test case for writing to a static property is throwing NPE.  I will try to see 
why this is.  Your proposed change to VariableExpressionTransformer or some 
kind of change in classgen may still be required.

> 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
>    Affects Versions: 3.0.0-rc-2
>            Reporter: Daniel Sun
>            Assignee: Eric Milles
>            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)

Reply via email to