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

Tweak plus operation for `Map` instance to align with Java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.3
    • None
    • None

    Description

      The string concatenation for Map instance of Groovy is not aligned with Java, e.g. the following code can not work:

      [a:1] + ' is a map'
      

      Here are the error messages:

      groovy.lang.MissingMethodException: No signature of method: java.util.LinkedHashMap.plus() is applicable for argument types: (String) values: [ is a map]
      Possible solutions: plus(java.util.Collection), plus(java.util.Map), values(), values(), values(), put(java.lang.Object, java.lang.Object)
      
      	at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:72)
      
      	at org.codehaus.groovy.vmplugin.v8.IndyGuardsFiltersAndSignatures.unwrap(IndyGuardsFiltersAndSignatures.java:172)
      
      	at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:318)
      
      	at ConsoleScript2.run(ConsoleScript2:1)
      
      	at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:268)
      
      	at groovy.lang.GroovyShell.run(GroovyShell.java:374)
      
      	at groovy.lang.GroovyShell.run(GroovyShell.java:353)
      
      	at groovy.lang.GroovyShell.run(GroovyShell.java:179)
      
      	at groovy.console.ui.Console$GroovySourceType.run(Console.groovy:1189)
      
      	at groovy.console.ui.Console.doRun(Console.groovy:1421)
      
      	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      
      	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
      
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
      
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
      
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:342)
      
      	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.callCurrent(PogoMetaClassSite.java:63)
      
      	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callCurrent(AbstractCallSite.java:203)
      
      	at groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy:1385)
      
      	at groovy.console.ui.Console$_runScriptImpl_closure23.doCall(Console.groovy)
      
      	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
      
      	at java.base/java.lang.reflect.Method.invoke(Method.java:577)
      
      	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:343)
      
      	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:328)
      
      	at org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:279)
      
      	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1009)
      
      	at groovy.lang.Closure.call(Closure.java:418)
      
      	at groovy.lang.Closure.call(Closure.java:412)
      
      	at groovy.lang.Closure.run(Closure.java:500)
      
      	at java.base/java.lang.Thread.run(Thread.java:833)
      
      

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              daniel_sun Daniel Sun
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: