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

CachedMethod.compareToCachedMethod throws "Should never happen"

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.4.6
    • Fix Version/s: 2.4.7
    • Component/s: groovy-jdk, groovy-runtime
    • Labels:
      None
    • Environment:
      Groovy Version: 2.4.6 JVM: 1.8.0_72 Vendor: Oracle Corporation OS: Linux

      Description

      When running the code below:

      String.metaClass.methods.unique()
      

      The exception occurs:

      Exception in thread "main" java.lang.RuntimeException: Should never happen
      	at org.codehaus.groovy.reflection.CachedMethod.compareToCachedMethod(CachedMethod.java:171)
      	at org.codehaus.groovy.reflection.CachedMethod.compareTo(CachedMethod.java:140)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareToWithEqualityCheck(DefaultTypeTransformation.java:588)
      	at org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.compareTo(DefaultTypeTransformation.java:543)
      	at org.codehaus.groovy.runtime.NumberAwareComparator.compare(NumberAwareComparator.java:34)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.numberAwareCompareTo(DefaultGroovyMethods.java:1119)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.coercedEquals(DefaultGroovyMethods.java:11493)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.unique(DefaultGroovyMethods.java:1071)
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.unique(DefaultGroovyMethods.java:1044)
      	at org.codehaus.groovy.runtime.dgm$739.invoke(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite$PojoMetaMethodSiteNoUnwrapNoCoerce.invoke(PojoMetaMethodSite.java:274)
      	at org.codehaus.groovy.runtime.callsite.PojoMetaMethodSite.call(PojoMetaMethodSite.java:56)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:117)
      	at com.study.Main.run(Main.groovy:3)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	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:93)
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1212)
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1021)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:923)
      	at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:906)
      	at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:410)
      	at org.codehaus.groovy.runtime.InvokerHelper$runScript.call(Unknown Source)
      	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)
      	at com.study.Main.main(Main.groovy)
      

      It is seen that is being compared to the same cached method with distinct instances. It should be treated as a cached method?

      self.toString()
      (Java.lang.String) public boolean java.lang.String.equals (java.lang.Object)
      
      other.toString()
      (Java.lang.String) public boolean java.lang.Object.equals (java.lang.Object)
      

      Thanks!

        Activity

        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user paulk-asert opened a pull request:

        https://github.com/apache/groovy/pull/315

        GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never …

        …happen"

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/paulk-asert/groovy groovy7820

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/groovy/pull/315.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #315


        commit f61d0329295ff1be1f6f0f683c27c9c0bddae95a
        Author: paulk <paulk@asert.com.au>
        Date: 2016-04-21T04:50:50Z

        GROOVY-7820: CachedMethod.compareToCachedMethod throws "Should never happen"


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user paulk-asert opened a pull request: https://github.com/apache/groovy/pull/315 GROOVY-7820 : CachedMethod.compareToCachedMethod throws "Should never … …happen" You can merge this pull request into a Git repository by running: $ git pull https://github.com/paulk-asert/groovy groovy7820 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/groovy/pull/315.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #315 commit f61d0329295ff1be1f6f0f683c27c9c0bddae95a Author: paulk <paulk@asert.com.au> Date: 2016-04-21T04:50:50Z GROOVY-7820 : CachedMethod.compareToCachedMethod throws "Should never happen"
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/groovy/pull/315

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/groovy/pull/315
        Hide
        paulk Paul King added a comment - - edited

        merged proposed PR, thanks for reporting the issue

        Show
        paulk Paul King added a comment - - edited merged proposed PR, thanks for reporting the issue
        Hide
        ftmamud Felipe Mamud added a comment -

        Thanks!

        Show
        ftmamud Felipe Mamud added a comment - Thanks!

          People

          • Assignee:
            paulk Paul King
            Reporter:
            ftmamud Felipe Mamud
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development