[
https://issues.apache.org/jira/browse/GROOVY-9193?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles closed GROOVY-9193.
-------------------------------
Resolution: Cannot Reproduce
> SC: Script method with default arguments throws IncompatibleClassChangeError
> ----------------------------------------------------------------------------
>
> Key: GROOVY-9193
> URL: https://issues.apache.org/jira/browse/GROOVY-9193
> Project: Groovy
> Issue Type: Bug
> Reporter: Eric Milles
> Priority: Minor
>
> Follow up from GROOVY-9151. Consider the following Groovy script:
> {code:groovy}
> @groovy.transform.CompileStatic
> void greet(Object o = 'world', String s = o.toString()) {
> print "hello $s"
> }
> greet()
> {code}
> NOTE: If the first parameter is changed to any type besides {{Object}}, the
> script runs as expected. So there must be some special handling for the
> dynamic parameter type.
> When executed this script throws the following exception:
> {code}
> Exception in thread "main" java.lang.IncompatibleClassChangeError: Expected
> static method java.lang.Object.toString()Ljava/lang/String;
> at Transient.greet(Transient.groovy:13)
> at
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at Transient.run(Transient.groovy:17)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:123)
> at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1280)
> at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1045)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1030)
> at
> org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1013)
> at
> org.codehaus.groovy.runtime.InvokerHelper.runScript(InvokerHelper.java:442)
> at
> org.codehaus.groovy.vmplugin.v7.IndyInterface.selectMethod(IndyInterface.java:234)
> at script.main(script.groovy)
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)