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

[jira] [Updated] (GROOVY-2242) Missing information in Javadoc of ExpandoMetaClass.enableGlobally()

     [ https://issues.apache.org/jira/browse/GROOVY-2242?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Pascal Schumacher updated GROOVY-2242:
--------------------------------------
    Affects Version/s: 2.4.5

> Missing information in Javadoc of ExpandoMetaClass.enableGlobally()
> -------------------------------------------------------------------
>
>                 Key: GROOVY-2242
>                 URL: https://issues.apache.org/jira/browse/GROOVY-2242
>             Project: Groovy
>          Issue Type: Bug
>          Components: Documentation
>    Affects Versions: 2.4.5
>            Reporter: Hans Dockter
>            Priority: Minor
>             Fix For: 2.4.6
>
>
> I was surprised by the following behavior:
> {code}
> class Person {
>     Object invokeMethod(String name, Object args) {
>         return false
>     }
> }
> def person1 = new Person()
> Person.metaClass.newMethod = { ->
>    return true
> }
> assert new Person().newMethod()
> assert person1.newMethod()
> {code}
> The last assert only works, if I set ExpandoMetaClass.enableGlobally() at the beginning of the script
> The javadoc of enableGlobally says:
> bq. Call to enable global use of global use of ExpandoMetaClass within the registry. This has the advantage that inheritance will function correctly, but has a higher memory usage on the JVM than normal Groovy
> The above use case should be added to the javadoc. 
> I guess with Groovy 2.0 things will become more intuitive anyway :)



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