Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow for set super.property within getter override under @CompileStatic #985

Closed
eric-milles opened this issue Nov 3, 2019 · 1 comment
Assignees
Labels
Milestone

Comments

@eric-milles
Copy link
Member

eric-milles commented Nov 3, 2019

Consider the following:

@groovy.transform.CompileStatic
class One7300 {
  private String string = 'value'
  String getString() { return string }
  void setString(String value) { string = value }
}

@groovy.transform.CompileStatic
class Two7300 extends One7300 {
  @Override
  String getString() {
    super.string = 'whatever'
    return super.string
  }
}

println new Two7300().string

Fix for #935 had reintroduced stack overflow of GROOVY-7300 during runtime. See org.codehaus.groovy.classgen.asm.sc.StaticPropertyAccessHelper.PoppingMethodCallExpression#PoppingMethodCallExpression(Expression, MethodNode, TemporaryVariableExpression).

Exception in thread "main" java.lang.StackOverflowError
	at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)
	at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)
	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:123)
	at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
	at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1317)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1269)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:144)
	at bugs.Two7300.getString(Groovy7300.groovy:15)
	...
	at bugs.Two7300.getString(Groovy7300.groovy:15)
	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:123)
	at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)
	at groovy.lang.MetaClassImpl.invokePropertyOrMissing(MetaClassImpl.java:1317)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1269)
	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:144)
	at bugs.Two7300.getString(Groovy7300.groovy:15)
	at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:123)
	at groovy.lang.MetaBeanProperty.getProperty(MetaBeanProperty.java:59)

@eric-milles eric-milles added the bug label Nov 3, 2019
@eric-milles
Copy link
Member Author

super.string = 'whatever' can be replaced with super.@string = 'whatever' or super.setString('whatever') to avoid the stack overflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant