[
https://issues.apache.org/jira/browse/GROOVY-11070?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17725741#comment-17725741
]
Jochen Theodorou commented on GROOVY-11070:
-------------------------------------------
If we restrict the support to -size..+(size-1) we could do a simple
{code:Java}
private static int cal(int i, Object[] foo) {
if (i>=0) return i;
return foo.length + i;
}
{code}
maybe even directly compiled into the bytecode and the performance overhead
seems to be negligible
> ObjectArrayStaticTypesHelper does not handle negative indices
> -------------------------------------------------------------
>
> Key: GROOVY-11070
> URL: https://issues.apache.org/jira/browse/GROOVY-11070
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 4.0.12
> Reporter: Christopher Smith
> Priority: Minor
>
> In general, the index-based DGM {{getAt}} has the convenient feature of
> wrapping negative indices to "from-the-end"-based indices. However, the STC's
> implementation of {{getAt}} for arrays (in {{ObjectArrayStaticTypesHelper}}
> and the companion classes) does not do this an instead throws AIOOBE on a
> negative index. It should have consistent behavior with other indexing types.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)