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 2022/02/03 22:33:00 UTC

[jira] [Closed] (GROOVY-10319) Groovy3 CompileStatic bug: Method clone is protected in java.lang.Object

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

Paul King closed GROOVY-10319.
------------------------------

> Groovy3 CompileStatic bug: Method clone is protected in java.lang.Object
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-10319
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10319
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 3.0.8
>         Environment: JDK11 (11.0.12)
>            Reporter: Olof Asbrink
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-beta-2, 3.0.10
>
>
> The following code compiles on groovy 2 but does not compile on groovy 3
> {code:java}
> package a.b.c
> import groovy.transform.CompileStatic
> @CompileStatic
> class ABC implements DEF {
>     public double[] _array
>     ABC() { }
>     DEF clone() {
>         ABC abc = (ABC) super.clone()
>         abc._array = _array.clone() as double[]
>         return abc
>     }
> }
> public interface DEF extends Cloneable {
>     public DEF clone() throws CloneNotSupportedException;
> }
>  {code}
> It gives the following error message:
> {code:java}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> ABC.groovy: 15: Method clone is protected in java.lang.Object @ line 15, column 22.
>            abc._array = _array.clone() as double[]
>                         ^
> 1 error
> {code}
> However if I don't put the class in a package (i.e. remove {{package a.b.c}}) it compiles fine.
> (this might relate to this issue GROOVY-9874)



--
This message was sent by Atlassian Jira
(v8.20.1#820001)