[ https://issues.apache.org/jira/browse/GROOVY-11371?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles reassigned GROOVY-11371: ------------------------------------ Assignee: Eric Milles > unsafe conversion of array of reference type to an array of primitive type > -------------------------------------------------------------------------- > > Key: GROOVY-11371 > URL: https://issues.apache.org/jira/browse/GROOVY-11371 > Project: Groovy > Issue Type: Bug > Components: Static Type Checker > Reporter: Thodoris Sotiropoulos > Assignee: Eric Milles > Priority: Minor > > I have the following program > {code:java} > class Test { > public static void main(String[] args) { > double[] z = new Double[]{null}; > } > } {code} > h3. Actual behavior > The compiler accepts the program. However, I get the following exception at > runtime. > > {code:java} > Exception in thread "main" java.lang.IllegalArgumentException > at java.base/java.lang.reflect.Array.set(Native Method) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.asArray(DefaultTypeTransformation.java:459) > at > org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation.castToType(DefaultTypeTransformation.java:228) > at > org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:336) > at Test.main(test.groovy:3) > {code} > h3. Expected behavior > The compiler should reject the program: Double[] is not convertible to > double[]. > h3. Notes > Tested against master (commit: 8ba8e8264fc3edeb9c70b52937edb97b0246a5d5) > Groovy 4.0.10 rejects the program as expected. -- This message was sent by Atlassian Jira (v8.20.10#820010)