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

CachedMethod.compareToCachedMethod throws "Should never happen"

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.6
    • 2.4.7
    • groovy-jdk, groovy-runtime
    • None
    • 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!

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: