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

@CompileStatic @Canonical inner class throws RTE: NoSuchMethodError: java.util.Map.withDefault

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.0.9
    • 4.0.0-beta-2, 3.0.15
    • Compiler
    • None
    • Windows 10, Java 11.0.11, IntelliJ 2021.1.1

    Description

      Another when-the-stars-align-bug:

      package org.groovy.groovybugs.v3_0_9
      
      import groovy.transform.Canonical
      import groovy.transform.CompileStatic
      import org.junit.jupiter.api.Test
      
      class Groovy_3_0_9_MapWithDefaultBug {
      
      	@Test
      	void groovy_3_0_9_MapWithDefaultBug() {
      	 final o = new Goo()
      	 println "o=$o"
      	}
       
      	@Canonical
      	@CompileStatic
      	static class Goo {
      		/*
      		 Groovy 3.0.9:
      		  * Every line below throws: "java.lang.NoSuchMethodError: 'java.util.Map java.util.Map.withDefault(groovy.lang.Closure)'"
      		  * Error only occurs for:
      		  ## (static) inner class
      		  ## @Canonical and @CompileStatic on inner class
      		*/
      		Map<String,Object> m0 = [:].withDefault { new Object() }
      		Map<String,Object> m1 = [:].withDefault { "abc" }
      		Map<String,Object> m2 = [:].withDefault { null }
      		Map m3 = [:].withDefault { null }
      	}
      }
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              emge mgroovy
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: