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 2022/07/29 13:09:00 UTC

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

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

Eric Milles resolved GROOVY-10695.
----------------------------------
    Fix Version/s: 5.0.0-alpha-1
       Resolution: Fixed

https://github.com/apache/groovy/commit/5466ff36b90c8e8ac17374c65a77f9cd1b5d52f7

> 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: 2.5.18, 3.0.12, 4.0.4
>            Reporter: Andres Luuk
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: StackOverflowError
>             Fix For: 5.0.0-alpha-1
>
>
> 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.
> {code:java}
>         test.Environment.setCurrentReloadError(Environment.groovy:8)
>         jdk.internal.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
>         java.base&#47;jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>         java.base&#47;java.lang.reflect.Method.invoke(Method.java:566)
>         org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
>         groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
>         groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:2839)
>         groovy.lang.MetaClassImpl.setProperty(MetaClassImpl.java:3854)
>         org.codehaus.groovy.runtime.InvokerHelper.setProperty(InvokerHelper.java:219)
>         org.codehaus.groovy.runtime.ScriptBytecodeAdapter.setProperty(ScriptBytecodeAdapter.java:496)
>         test.Environment.setCurrentReloadError(Environment.groovy:8){code}
> 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)