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

Eric Milles resolved GROOVY-9608.
---------------------------------
    Fix Version/s: 2.5.13
                   3.0.5
                   2.4.20
       Resolution: Fixed

getAttribute and setAttribute may throw MissingFieldException for cases where 
super field exists.  But at least they are not returning the incorrect field 
and the message is now accurate.

> MetaClassImpl.getAttribute(Class,Object,String,boolean) drops super
> -------------------------------------------------------------------
>
>                 Key: GROOVY-9608
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9608
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 2.4.19, 3.0.4, 2.5.12
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 2.4.20, 3.0.5, 2.5.13
>
>
> {{ScriptBytecodeAdapter.getFieldOnSuper}} calls 
> {{MetaClass#getAttribute(SuperType,thisObject,"fieldName",true)}}.   
>  {{MetaClassImpl}} delegates and drops the super flag in the process.
> {code:groovy}
> class A {
>   protected x = 1
> }
> class B extends A {
>   protected x = 1.0
> }
> def a = new A()
> println a.metaClass.getAttribute(A, a, 'x', false) // prints "1"
> def b = new B()
> println b.metaClass.getAttribute(B, b, 'x', false) // prints "1.0"
> println b.metaClass.getAttribute(A, b, 'x', true) // prints "1.0", but "1" is 
> expected
> println ScriptBytecodeAdapter.getFieldOnSuper(A, b, 'x') // prints "1.0", but 
> "1" is expected
> {code}



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

Reply via email to