You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/12/17 01:40:00 UTC

[jira] [Commented] (GROOVY-9861) parsing bug when inner class references top level class fields in groovy 3

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

Paul King commented on GROOVY-9861:
-----------------------------------

Okay with 3.0.5 but fails from 3.0.6.

> parsing bug when inner class references top level class fields in groovy 3
> --------------------------------------------------------------------------
>
>                 Key: GROOVY-9861
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9861
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.6, 3.0.7
>            Reporter: Howard
>            Priority: Major
>
> The follow code compiles fine under groovy 2 but does not compile under groovy 3
> {code:java}
> import groovy.transform.CompileStatic
> import java.awt.Color
> import java.awt.event.MouseAdapter
> import java.awt.event.MouseEvent
> @CompileStatic
> public class TreePair2 {
>     int clickCount = 0;
>     boolean isAprilFools = false;
>     private TreePair2() {
>     }
>     protected class TreeMouseClickHandler extends MouseAdapter {
>         @Override
>         public void mouseClicked(MouseEvent e) {
>             if(isAprilFools) {
>                 clickCount++;
>             }
>         }
>     }
> }
> {code}
> Error msg:
> {code:java}
> Exception thrown
> groovy.lang.GroovyRuntimeException: ASM reporting processing error for TreePair2$TreeMouseClickHandler#mouseClicked with signature void mouseClicked(java.awt.event.MouseEvent) in ConsoleScript77:18. ConsoleScript77
> 	at jdk.internal.reflect.GeneratedMethodAccessor56.invoke(Unknown Source)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
> 	at groovyjarjarasm.asm.Frame.merge(Frame.java:1268)
> 	at groovyjarjarasm.asm.Frame.merge(Frame.java:1244)
> 	at groovyjarjarasm.asm.MethodWriter.computeAllFrames(MethodWriter.java:1610)
> 	at groovyjarjarasm.asm.MethodWriter.visitMaxs(MethodWriter.java:1546)
> 	... 2 more{code}
> The problem seems to be with these 3 lines
> {code:java}
>             if(isAprilFools) {
>                 clickCount++;
>             }
> {code}
> if you just have
> {code:java}
> if(isAprilFools) { 
>   println(1) 
> }
> // it works
> // or just
> clickCount++;
> // also works
> // but when you add clickCount++ into the if statement, it fails
> {code}
> I also want to note that by removing staticcompilation, it seems to work.



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