Groovy
  1. Groovy
  2. GROOVY-5221

Problem with @InheritConstructors with multiple level of inheritance (part 1 of 2 - document the current limitation)

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.8.4
    • Fix Version/s: 1.8.6, 2.0-beta-3, 1.7.11
    • Component/s: Compiler
    • Labels:
      None

      Description

      See also GROOVY-5274 which will be the actual fix, changing the focus of this issue to updating the doco to outline the current limitations.

      =======================

      See test eclipse project attached.

      • Class Hierarchy : A <-- inherit – B <-- inherit – C
      • A define constructor public A(String dummy) {...}
      • B and C use @InheritConstructors.
      • In the main(...) : C.class.newInstance("tata")
      • Result : Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: data.C(java.lang.String)
        at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1474)
        at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1390)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:824)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.newInstance(DefaultGroovyMethods.java:17689)
        at org.codehaus.groovy.runtime.dgm$511.doMethodInvoke(Unknown Source)
        at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
        at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
        at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        at Main.MainLaunch.main(MainLaunch.groovy:7)

        Issue Links

          Activity

          ronan michaux created issue -
          Hide
          Jochen Theodorou added a comment -

          I assume that happens because C is visited before B is. Then the transform for C can simply not see the constructor added to B, because that did not yet happen. I guess @InheritConstructors would have to either run this transform on B first - out of the normal order - or delay evaluation of C, till B is done. The later could be done using the node meta data.

          Show
          Jochen Theodorou added a comment - I assume that happens because C is visited before B is. Then the transform for C can simply not see the constructor added to B, because that did not yet happen. I guess @InheritConstructors would have to either run this transform on B first - out of the normal order - or delay evaluation of C, till B is done. The later could be done using the node meta data.
          Hide
          Paul King added a comment -

          It would be nice to fix this but I wouldn't necessarily call it a blocker issue. If we don't fix it before the next release I guess we should at least update the doco indicating that it isn't currently supported before the next release.

          Show
          Paul King added a comment - It would be nice to fix this but I wouldn't necessarily call it a blocker issue. If we don't fix it before the next release I guess we should at least update the doco indicating that it isn't currently supported before the next release.
          Paul King made changes -
          Field Original Value New Value
          Link This issue is related to GROOVY-5274 [ GROOVY-5274 ]
          Paul King made changes -
          Description See test eclipse project attached.

          - Class Hierarchy : A <-- inherit -- B <-- inherit -- C

          - A define constructor public A(String dummy){...}

          - B and C use @InheritConstructors.

          - In the main(...) : C.class.newInstance("tata")

          - Result : Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: data.C(java.lang.String)
          at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1474)
          at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1390)
          at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:824)
          at org.codehaus.groovy.runtime.DefaultGroovyMethods.newInstance(DefaultGroovyMethods.java:17689)
          at org.codehaus.groovy.runtime.dgm$511.doMethodInvoke(Unknown Source)
          at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
          at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
          at Main.MainLaunch.main(MainLaunch.groovy:7)
          See also GROOVY-5274 which will be the actual fix, changing the focus of this issue to updating the doco to outline the current limitations.

          =======================

          See test eclipse project attached.

          - Class Hierarchy : A <-- inherit -- B <-- inherit -- C

          - A define constructor public A(String dummy){...}

          - B and C use @InheritConstructors.

          - In the main(...) : C.class.newInstance("tata")

          - Result : Exception in thread "main" groovy.lang.GroovyRuntimeException: Could not find matching constructor for: data.C(java.lang.String)
          at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1474)
          at groovy.lang.MetaClassImpl.invokeConstructor(MetaClassImpl.java:1390)
          at org.codehaus.groovy.runtime.InvokerHelper.invokeConstructorOf(InvokerHelper.java:824)
          at org.codehaus.groovy.runtime.DefaultGroovyMethods.newInstance(DefaultGroovyMethods.java:17689)
          at org.codehaus.groovy.runtime.dgm$511.doMethodInvoke(Unknown Source)
          at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)
          at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)
          at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
          at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
          at Main.MainLaunch.main(MainLaunch.groovy:7)
          Fix Version/s 1.8.6 [ 18245 ]
          Assignee Paul King [ paulk ]
          Paul King made changes -
          Summary Problem with @InheritConstructors with multiple level of inheritance Problem with @InheritConstructors with multiple level of inheritance (part 1 of 2 - current document the limitation)
          Paul King made changes -
          Summary Problem with @InheritConstructors with multiple level of inheritance (part 1 of 2 - current document the limitation) Problem with @InheritConstructors with multiple level of inheritance (part 1 of 2 - document the current limitation)
          Hide
          Paul King added a comment -

          Current limitation documented - it would be nice to fix the actual issue shortly but just in case this doesn't happen before the next release, at least the limitation will be more appararent

          Show
          Paul King added a comment - Current limitation documented - it would be nice to fix the actual issue shortly but just in case this doesn't happen before the next release, at least the limitation will be more appararent
          Paul King made changes -
          Fix Version/s 2.0-beta-3 [ 18244 ]
          Resolution Fixed [ 1 ]
          Status Open [ 1 ] Resolved [ 5 ]
          Fix Version/s 1.7.11 [ 17244 ]
          Paul King made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Mark Thomas made changes -
          Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
          Mark Thomas made changes -
          Workflow jira [ 12734144 ] Default workflow, editable Closed status [ 12745906 ]
          Mark Thomas made changes -
          Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
          Mark Thomas made changes -
          Workflow jira [ 12973745 ] Default workflow, editable Closed status [ 12980908 ]
          Transition Time In Source Status Execution Times Last Executer Last Execution Date
          Open Open Resolved Resolved
          35d 15h 24m 1 Paul King 02/Feb/12 03:28
          Resolved Resolved Closed Closed
          10d 34m 1 Paul King 12/Feb/12 04:03

            People

            • Assignee:
              Paul King
              Reporter:
              ronan michaux
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development