You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/12/05 22:19:00 UTC

[jira] [Resolved] (GROOVY-9609) ScriptBytecodeAdapter.getPropertyOnSuper fails with method missing for getProperty

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

Eric Milles resolved GROOVY-9609.
---------------------------------
    Fix Version/s: 4.0.0-rc-2
       Resolution: Fixed

https://github.com/apache/groovy/commit/b90128e8de4d728436586393a08c27bf90c44929

> ScriptBytecodeAdapter.getPropertyOnSuper fails with method missing for getProperty
> ----------------------------------------------------------------------------------
>
>                 Key: GROOVY-9609
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9609
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 4.0.0-rc-2
>
>
> {{ScriptBytecodeAdapter.getPropertyOnSuper}} calls {{invokeSuperMethodN(SuperType,thisObject,"getProperty", new Object[]\{"propertyName"\})}}, which calls {{thisObject.getMetaClass().invokeMethod(SuperType,thisObject,"getProperty", messageArguments, true, true)}}.  {{MetaClassImpl}}'s invokeMethod is failing to find public getProperty(String) method in class A.
> {code:groovy}
> class A {
>   def getX() { 'A' }
> }
> class B extends A {
>   def getX() { 'B' }
> }
> println new A().getProperty("x") // prints "A"
> println new B().getProperty("x") // prints "B"
> println ScriptBytecodeAdapter.getPropertyOnSuper(A, new B(), "x") // MissingMethodException: No signature of method: B.getProperty() is applicable for argument types: (String) values: [x]
> {code}
> Also, the message indicates that B is the type that was searched; it should display A.
> I found a similar result for {{ScriptBytecodeAdapter.getFieldOnSuper}} in GROOVY-9608.  I think there is something wrong with the cached super information in MetaClassImpl.  https://github.com/apache/groovy/blob/0b886e910bbb0e75aae527fae2cab0ec4f096bf2/src/test/groovy/bugs/Groovy9608.groovy#L53



--
This message was sent by Atlassian Jira
(v8.20.1#820001)