Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.5.18, 3.0.12, 4.0.4
-
None
Description
I tryed it on all 3.x versions (didn't try 2.x). Found it from Grails code but extracted it as an example
package test; public class Environment { public static Throwable currentReloadError = null static void setCurrentReloadError(Throwable currentReloadError) { Environment.currentReloadError = currentReloadError } static Throwable getCurrentReloadError() { return currentReloadError } }
Now when I call the setter:
Environment.setCurrentReloadError(null);
I get a StackOverflowError.
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)
I decompiled the class and the code is compiled into:
public static void setCurrentReloadError(Throwable currentReloadError) { Throwable throwable = currentReloadError; ScriptBytecodeAdapter.setProperty(throwable, null, Environment.class, "currentReloadError"); }
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.
Attachments
Issue Links
- links to