Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
I have the following program
class Test { public static void main(String[] args) { double[] z = new Double[]{null}; } }
Actual behavior
The compiler accepts the program. However, I get the following exception at runtime.
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)
Expected behavior
The compiler should reject the program: Double[] is not convertible to double[].
Notes
Tested against master (commit: 8ba8e8264fc3edeb9c70b52937edb97b0246a5d5)
Groovy 4.0.10 rejects the program as expected.
Attachments
Issue Links
- is related to
-
GROOVY-10359 STC misses type error when involving a variable with a char a declared type
-
- Open
-
-
GROOVY-10095 Wrong LUB when involving a numeric constant and null
-
- Resolved
-
-
GROOVY-9916 IllegalArgumentException when set null to a boolean field into a closure
-
- Closed
-
-
GROOVY-11203 IllegalArgumentException: null argument for primitive parameter
-
- Closed
-