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 2022/07/20 06:45:00 UTC

[jira] [Commented] (GROOVY-10695) StackOverflowError when calling a static method.

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

Paul King commented on GROOVY-10695:
------------------------------------

I haven't yet checked whether this is a regression but one workaround is:
{code:java}
        Environment.@currentReloadError = currentReloadError
{code}



> StackOverflowError when calling a static method.
> ------------------------------------------------
>
>                 Key: GROOVY-10695
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10695
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.11
>            Reporter: Andres Luuk
>            Priority: Major
>
> I tryed it on all 3.x versions (didn't try 2.x). Found it from Grails code but extracted it as an example
>  
> {code:java}
> package test;
> public class Environment {
>     public static Throwable currentReloadError = null
>     static void setCurrentReloadError(Throwable currentReloadError) {
>         Environment.currentReloadError = currentReloadError
>     }
>     static Throwable getCurrentReloadError() {
>         return currentReloadError
>     }
> }
> {code}
> Now when I call the setter:
>  
> {code:java}
> Environment.setCurrentReloadError(null);{code}
>  
> I get a StackOverflowError.
> I decompiled the class and the code is compiled into:  
> {code:java}
> public static void setCurrentReloadError(Throwable currentReloadError) {
>   Throwable throwable = currentReloadError;
>   ScriptBytecodeAdapter.setProperty(throwable, null, Environment.class, "currentReloadError");
> }{code}
>  
> The cause seems to be that it finds the same setter and this causes the circularity.
> If I remove the (Environment.) from the original code then it works.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)