Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Won't Fix
-
Affects Version/s: 1.0-JSR-5
-
Fix Version/s: 1.5
-
Component/s: None
-
Labels:None
-
Environment:WinXP SP2
-
Testcase included:yes
Description
------------------------------------------------------------
def list = [1,2,3,4,5,6,7,8,9]
println list[99] // null is returned
println list[-99] // throws java.lang.ArrayIndexOutOfBoundsException
------------------------------------------------------------
Stack trace:
Caught: java.lang.ArrayIndexOutOfBoundsException: Negative array index [-99] too large for array size 9
at test.run(test.groovy:5)
at test.main(test.groovy)
To me, this seems to be inconsistent behavior for two similar expressions.
the same method normaliseIndex is used both for putAt & getAt. An ArrayIndexOutOfBoundsException
have to be thrown for getAt when index is greater than size.