You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Nils Kuhn (JIRA)" <ji...@apache.org> on 2015/10/05 16:07:26 UTC

[jira] [Commented] (GROOVY-7295) ConfigObject instance can't be coerced into trait in runtime

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

Nils Kuhn commented on GROOVY-7295:
-----------------------------------

Seems that the following solution to expose i18n resource bundles to javascript code in a grails application doesn't work due to this bug :(
http://www.razum.si/blog/grails-javascript-i18n-messages


> ConfigObject instance can't be coerced into trait in runtime
> ------------------------------------------------------------
>
>                 Key: GROOVY-7295
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7295
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.0
>            Reporter: Pavel
>
> It works with other classes, even Java (Integer for example):
> {code}
> trait Extra {
>     String extra() { "I'm an extra method" }
> }
> class Something {
>     String doSomething() { 'Something' }
> }
> def s = new Something() as Extra;
> assert "I'm an extra method" == s.extra()
> assert 'Something' == s.doSomething()
> def i = new Integer(0) as Extra;
> assert "I'm an extra method" == i.extra()
> def conf = new ConfigSlurper().parse('some = 7')
> // Uncomment it and you are receive error:
> // def ss = conf as Extra
> /*
> java.lang.NoClassDefFoundError: Extra
>     at ConsoleScript24.run(ConsoleScript24:16)
> Caused by: java.lang.ClassNotFoundException: Extra
>     ... 1 more
> */
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)