Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-10302

StackOverflowError on Java 16+ for override method that delegates to super

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.0-beta-1
    • 4.0.0-rc-2
    • jdk conflict
    • None

    Description

      Consider the following:

      void test() {
          def list = []
      
          def loader = new GroovyClassLoader() {
              @Override
              protected Class<?> findClass(String name) throws ClassNotFoundException {
                  list.add(name); super.findClass(name)
              }
          }
      
          Class result = loader.findClass('foo.bar.Baz')
      }
      

      When executed on Java 16+ it produces a StackOverflowError when resolving "super.findClass(name)".

          java.lang.StackOverflowError
              at org.codehaus.groovy.runtime.memoize.LRUCache.getAndPut(LRUCache.java:63)
              at org.codehaus.groovy.vmplugin.v8.CacheableCallSite.getAndPut(CacheableCallSite.java:48)
              at org.codehaus.groovy.vmplugin.v8.IndyInterface.lambda$fromCache$2(IndyInterface.java:298)
              at org.codehaus.groovy.vmplugin.v8.IndyInterface.doWithCallSite(IndyInterface.java:367)
              at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:295)
              at TestScript0$1.findClass(TestScript0.groovy:8)
              at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:567)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:116)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
              at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1424)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1140)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:146)
              at TestScript0$1.findClass(TestScript0.groovy:8)
              at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:567)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:116)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
              at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1424)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1140)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:146)
              at TestScript0$1.findClass(TestScript0.groovy:8)
              at java.base/jdk.internal.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
              at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.base/java.lang.reflect.Method.invoke(Method.java:567)
              at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:116)
              at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
              at groovy.lang.MetaClassImpl.doInvokeMethod(MetaClassImpl.java:1424)
              at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1140)
              at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnSuperN(ScriptBytecodeAdapter.java:146)
              at TestScript0$1.findClass(TestScript0.groovy:8)
      

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: