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/20 10:40:00 UTC
[jira] [Assigned] (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 reassigned GROOVY-10695:
------------------------------------
Assignee: Eric Milles
> 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
> Assignee: Eric Milles
> 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.
> {code:java}
> test.Environment.setCurrentReloadError(Environment.groovy:8)
> jdk.internal.reflect.GeneratedMethodAccessor47.invoke(Unknown Source)
> java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> java.base/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)