[ 
https://issues.apache.org/jira/browse/GROOVY-10405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17500857#comment-17500857
 ] 

Eric Milles edited comment on GROOVY-10405 at 3/3/22, 4:16 PM:
---------------------------------------------------------------

The issue lies in {{AutoClone}}'s "super.clone()" call to start out the cloning 
process.  Under Java 17, the meta method index does not get {{methodForSuper}} 
populated for clone.  Using {{@CompileStatic}} will create a direct method call 
in the bytecode instead of routing through 
{{ScriptBytecodeAdapter#invokeMethodOnSuper0}}.

There was a significant overhaul of the super method indexing for Groovy 4.  It 
is not safe to backport this to Groovy 3.


was (Author: emilles):
The issue lies in {{AutoClone}}'s "super.clone()" call to start out the cloning 
process.  Under Java 17, the meta method index does not get {{methodForSuper}} 
populated for clone.  Using {{@CompileStatic}} will create a direct method call 
in the bytecode instead of routing through 
{{ScriptBytecodeAdapter#invokeMethodOnSuper0}}.

> @AutoClone breaks in Java17 for File properties
> -----------------------------------------------
>
>                 Key: GROOVY-10405
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10405
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.9
>         Environment: Java11 vs Java17
> Windows10, Ubuntu
>            Reporter: Aleks Tamarkin
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-rc-1
>
>
> The following code works on Java11 but breaks on Java17
>  
> {code:java}
> import groovy.transform.AutoClone
> @AutoClone
> class Foo {
>     File file
>     String string
> }
> def foo = new Foo(file: new File('bar'), string: 'qux')
> foo.clone()
> {code}
> The error is
> {code:java}
> groovy.lang.MissingMethodException: No signature of method: 
> java.lang.Object.clone() is applicable for argument types: () values: []
> Possible solutions: collect(), collect(groovy.lang.Closure), 
> collect(java.util.Collection, groovy.lang.Closure), find(), any(), 
> use([Ljava.lang.Object;){code}
> This can be reproduced in GroovyConsole



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

Reply via email to