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

Unable to access an outer class static method from a super call in the inner-class constructor

    XMLWordPrintableJSON

    Details

      Description

      The following code

      import groovy.transform.*
      
      //@CompileStatic
      class X {
          
          final Y y = new Y();
          
          public static List<String> l() {
              return Arrays.asList("a", "b");
          }
          
          class Y extends ArrayList<String> {
              Y() {
                  super(l());
              }
          }
      }
      
      new X()
      

      works fine with @CompileStatic but doesn't work without it.

      Full stack trace:

      Apr 17, 2013 2:48:57 PM org.codehaus.groovy.runtime.StackTraceUtils sanitize
      WARNING: Sanitizing stacktrace:
      groovy.lang.MissingMethodException: No signature of method: static X$Y.l() is applicable for argument types: () values: []
      Possible solutions: is(java.lang.Object), any(), min(), last(), pop(), tail()
      	at groovy.lang.MetaClassImpl.invokeStaticMissingMethod(MetaClassImpl.java:1373)
      	at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1359)
      	at org.codehaus.groovy.runtime.callsite.StaticMetaClassSite.callStatic(StaticMetaClassSite.java:62)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallStatic(CallSiteArray.java:53)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:157)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callStatic(AbstractCallSite.java:161)
      	at X$Y.<init>(super_call_bug.groovy:14)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
      	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
      	at X.<init>(super_call_bug.groovy:6)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
      	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
      	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
      	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
      	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:57)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:182)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:186)
      	at super_call_bug.run(super_call_bug.groovy:19)
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:257)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:481)
      	at groovy.lang.GroovyShell.run(GroovyShell.java:163)
      	at groovy.lang.GroovyShell$run.call(Unknown Source)
      	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy:951)
      	at groovy.ui.Console$_runScriptImpl_closure17.doCall(Console.groovy)
      	at sun.reflect.GeneratedMethodAccessor207.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      	at java.lang.reflect.Method.invoke(Method.java:597)
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:233)
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:272)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:909)
      	at groovy.lang.Closure.call(Closure.java:411)
      	at groovy.lang.Closure.call(Closure.java:405)
      	at groovy.lang.Closure.run(Closure.java:492)
      	at java.lang.Thread.run(Thread.java:662)
      
      groovy.lang.MissingMethodException: No signature of method: static X$Y.l() is applicable for argument types: () values: []
      Possible solutions: is(java.lang.Object), any(), min(), last(), pop(), tail()
      	at X$Y.<init>(super_call_bug.groovy:14)
      	at X.<init>(super_call_bug.groovy:6)
      	at super_call_bug.run(super_call_bug.groovy:19)
      

        Attachments

        1. super_call_bug.groovy
          0.3 kB
          Dmitry Ovchinnikov

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              dmovchinn Dmitry Ovchinnikov
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: