You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Iurii (JIRA)" <ji...@apache.org> on 2017/03/29 15:12:41 UTC
[jira] [Updated] (GROOVY-8136) Code passes static compilation but
fails during runtime
[ https://issues.apache.org/jira/browse/GROOVY-8136?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Iurii updated GROOVY-8136:
--------------------------
Description:
Input files:
Test.groovy
{code}
class Test {
static org.springframework.util.MultiValueMap map = [:] // class from spring-core:4.2.6-RELEASE
static void main(String[] args) {
println map
}
}
{code}
compiler-config.groovy
{code}
import groovy.transform.CompileStatic
withConfig(configuration)
{ ast(CompileStatic) }
{code}
Error: {code}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)
{code}
Expected behavior: either compile time error or handle it correctly during runtime
was:
Input files:
Test.groovy
{code}
class Test {
static org.springframework.util.MultiValueMap map = [:] // class from spring-core:4.2.6-RELEASE
static void main(String[] args) {
println map
}
}
{code}
compiler-config.groovy
{code}
import groovy.transform.CompileStatic
withConfig(configuration)
{ ast(CompileStatic) }
{code}
Error: {code}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)
{code}
Expected behavior: compile time error
> Code passes static compilation but fails during runtime
> -------------------------------------------------------
>
> Key: GROOVY-8136
> URL: https://issues.apache.org/jira/browse/GROOVY-8136
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.4.10
> Environment: Windows 7, JDK 1.8.0_66
> Reporter: Iurii
>
> Input files:
> Test.groovy
> {code}
> class Test {
> static org.springframework.util.MultiValueMap map = [:] // class from spring-core:4.2.6-RELEASE
> static void main(String[] args) {
> println map
> }
> }
> {code}
> compiler-config.groovy
> {code}
> import groovy.transform.CompileStatic
> withConfig(configuration)
> { ast(CompileStatic) }
> {code}
> Error: {code}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)
> {code}
> Expected behavior: either compile time error or handle it correctly during runtime
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)