[
https://issues.apache.org/jira/browse/GROOVY-6656?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15410905#comment-15410905
]
Paul King commented on GROOVY-6656:
-----------------------------------
This seems to have been fixed in master:
{noformat}
Method clone is protected in java.lang.Object at line: 15, column: 41
{noformat}
> Add compiler error when Object.clone method is called in CompileStatic mode.
> Currently causes VerifyError "Bad access to protected data" at runtime
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: GROOVY-6656
> URL: https://issues.apache.org/jira/browse/GROOVY-6656
> Project: Groovy
> Issue Type: Bug
> Components: Static compilation
> Affects Versions: 2.2.2, 2.3.0, 2.4.0-rc-1
> Reporter: Lari Hotari
>
> The compiler should issue an error when Object.clone method is called in
> CompileStatic mode.
> This currently causes VerifyError "Bad access to protected data" at runtime
> which doesn't really point out the problem.
> Here's a code example that demonstrates the problem:
> {code}
> @groovy.transform.CompileStatic
> class Person {
> String name
>
> public Object clone() {
> new Person(name: name)
> }
> }
> @groovy.transform.CompileStatic
> Person cloneIt(Object param) {
> (Person)param.clone()
> }
> cloneIt(new Person(name:'Lari')).name
> {code}
> this fails with error at class loading time (at runtime):
> {code}
> java.lang.VerifyError: (class: ConsoleScript21, method: cloneIt signature:
> (Ljava/lang/Object;)LPerson;) Bad access to protected data
> {code}
> I believe that the expected behaviour would be to fail with compiler error at
> compile time.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)