groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;}

Apache's JIRA Issue Tracker | James Parkin | 8 years ago
tip
Click on the to mark the solution that helps you, Samebug will learn from it.
As a community member, you’ll be rewarded for you help.
  1. 0

    Running the following code cause an Ambiguous method overloading exception: str = 'hello' methodName = 'toUpperCase' methodOfInterest = str.metaClass.getMetaMethod(methodName) println methodOfInterest.invoke(str) Expected output: HELLO Exception details: Exception in thread "main" groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;} at groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:2866) at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2819) at groovy.lang.MetaClassImpl.getNormalMethodWithCaching(MetaClassImpl.java:1228) at groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:1131) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163) at MOPUsingMetaMethod.run(MOPUsingMetaMethod.groovy:4) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 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:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1061) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719) at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:381) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 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:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1301) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:710) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163) at MOPUsingMetaMethod.main(MOPUsingMetaMethod.groovy) This functionality does work in groovy 1.5.7 so appears to have regressed in 1.6.0. Using the pickMethod instead of getMetaMethod produces the expected output.

    Apache's JIRA Issue Tracker | 8 years ago | James Parkin
    groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;}
  2. 0

    Running the following code cause an Ambiguous method overloading exception: str = 'hello' methodName = 'toUpperCase' methodOfInterest = str.metaClass.getMetaMethod(methodName) println methodOfInterest.invoke(str) Expected output: HELLO Exception details: Exception in thread "main" groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;} at groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:2866) at groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2819) at groovy.lang.MetaClassImpl.getNormalMethodWithCaching(MetaClassImpl.java:1228) at groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:1131) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163) at MOPUsingMetaMethod.run(MOPUsingMetaMethod.groovy:4) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 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:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1061) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892) at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719) at org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:381) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 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:86) at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234) at groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1301) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:710) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163) at MOPUsingMetaMethod.main(MOPUsingMetaMethod.groovy) This functionality does work in groovy 1.5.7 so appears to have regressed in 1.6.0. Using the pickMethod instead of getMetaMethod produces the expected output.

    Apache's JIRA Issue Tracker | 8 years ago | James Parkin
    groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;}

    Root Cause Analysis

    1. groovy.lang.GroovyRuntimeException

      Ambiguous method overloading for method org.codehaus.groovy.runtime.HandleMetaClass#getMetaMethod. Cannot resolve which method to invoke for {class java.lang.String} due to overlapping prototypes between: {class java.lang.String, class [Ljava.lang.Object;} {class java.lang.String, class [Ljava.lang.Class;}

      at groovy.lang.MetaClassImpl.chooseMostSpecificParams()
    2. Groovy
      ScriptBytecodeAdapter.invokeMethodN
      1. groovy.lang.MetaClassImpl.chooseMostSpecificParams(MetaClassImpl.java:2866)
      2. groovy.lang.MetaClassImpl.chooseMethod(MetaClassImpl.java:2819)
      3. groovy.lang.MetaClassImpl.getNormalMethodWithCaching(MetaClassImpl.java:1228)
      4. groovy.lang.MetaClassImpl.getMethodWithCaching(MetaClassImpl.java:1131)
      5. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:910)
      6. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892)
      7. org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736)
      8. org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719)
      9. org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163)
      9 frames
    3. Unknown
      MOPUsingMetaMethod.run
      1. MOPUsingMetaMethod.run(MOPUsingMetaMethod.groovy:4)
      1 frame
    4. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    5. Groovy
      InvokerHelper.runScript
      1. org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      2. groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
      3. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1061)
      4. groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:892)
      5. org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:736)
      6. org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:719)
      7. org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:381)
      7 frames
    6. Java RT
      Method.invoke
      1. sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      2. sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      3. sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      4. java.lang.reflect.Method.invoke(Method.java:597)
      4 frames
    7. Groovy
      ScriptBytecodeAdapter.invokeMethodN
      1. org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:86)
      2. groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:234)
      3. groovy.lang.MetaClassImpl.invokeStaticMethod(MetaClassImpl.java:1301)
      4. org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:710)
      5. org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(ScriptBytecodeAdapter.java:163)
      5 frames
    8. Unknown
      MOPUsingMetaMethod.main
      1. MOPUsingMetaMethod.main(MOPUsingMetaMethod.groovy)
      1 frame