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

Paul King commented on GROOVY-9707:
-----------------------------------

The following shorter Groovy script exhibits the problem:
{code:java}
import groovy.lang.GroovyClassLoader
import groovy.transform.CompileStatic
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer

String script = '''@groovy.transform.TypeChecked
    class NoSuchMethodTest {
        void invoke() {
            'a' + 'b'
        }
    }
'''

def config = new CompilerConfiguration()
config.addCompilationCustomizers(new ASTTransformationCustomizer(CompileStatic))
def loader = new GroovyClassLoader(Thread.currentThread().contextClassLoader, 
config)
loader.parseClass(script).getConstructor().newInstance().invoke()
{code}
Removing the explicit {{TypeChecked}} in the script (since it is not needed) or 
aligning it with what is added via compiler customization (to avoid the 
misalignment) fixes the problem but we shouldn't have this error even if the 
poor style is left as is.

> TypeChecked: NoSuchMethodError: DefaultGroovyMethods.plus(java.lang.String, 
> java.lang.Object)
> ---------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9707
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9707
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.0.5
>            Reporter: Radoslav Ivanov
>            Priority: Major
>
> Looking for advice around resolving a problem after upgrading Groovy from 
> 2.5.9 to 3.0.5. 
> Most of the @TypeChecked scripts start hitting NoSuchMethodError when 
> concatenating two strings ("a" + "b"), which is resolved if @TypeChecked is 
> removed... The removed method's deprecation java doc (in 2.4.7) says to "Use 
> the CharSequence version"...
> {code:java}
> java.lang.NoSuchMethodError: 'java.lang.String 
> org.codehaus.groovy.runtime.DefaultGroovyMethods.plus(java.lang.String, 
> java.lang.Object){code}
> May be I am missing something.. any advice will be appreciated...



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

Reply via email to