You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2021/04/14 04:07:00 UTC

[jira] [Resolved] (GROOVY-10034) Compiler writes extra cast for Type[] to Object[]

     [ https://issues.apache.org/jira/browse/GROOVY-10034?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King resolved GROOVY-10034.
--------------------------------
    Fix Version/s: 4.0.0-beta-1
       Resolution: Fixed

Proposed PR merged.

> Compiler writes extra cast for Type[] to Object[]
> -------------------------------------------------
>
>                 Key: GROOVY-10034
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10034
>             Project: Groovy
>          Issue Type: Improvement
>          Components: bytecode
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-beta-1
>
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> ['x'].toArray(new String[0])
> {code}
> This produces a bytecode sequence that includes a cast from {{String[]}} to {{Object[]}}.  javac for the same code omits the cast.
> {code}
>      9  iconst_0
>     10  multianewarray java.lang.String[] [44]
>     14  invokedynamic 0 cast(java.lang.String[]) : java.lang.Object[] [58]
>     19  invokeinterface java.util.Collection.toArray(java.lang.Object[]) : java.lang.Object[] [64] [nargs: 2]
> {code}
> Note: {{multianewarray}} vs {{anewarray}} was fixed by GROOVY-10031



--
This message was sent by Atlassian Jira
(v8.3.4#803005)