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

Code passes static compilation but fails during runtime

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.10
    • 3.0.15, 2.5.22
    • Static Type Checker
    • None

    Description

      Input files:
      Test.groovy

      class Test {
          static org.springframework.util.MultiValueMap map = [:] // class from spring-core:4.2.6-RELEASE
      
          static void main(String[] args) {
              println map
          }
      }
      

      compiler-config.groovy

      import groovy.transform.CompileStatic
      withConfig(configuration)
      { ast(CompileStatic) }
      

      Error:

      org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object '{}' with class 'java.util.LinkedHashMap' to class 'org.springframework.util.MultiValueMap' due to: groovy.lang.GroovyRuntimeException: Could not find matching constructor for: org.springframework.util.MultiValueMap(java.util.LinkedHashMap)
      

      Expected behavior: either compile time error or handle it correctly during runtime

      Attachments

        Activity

          People

            emilles Eric Milles
            ichulovskyi Iurii
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: