Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9609

ScriptBytecodeAdapter.getPropertyOnSuper fails with method missing for getProperty

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-rc-2
    • None
    • None

    Description

      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.

      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]
      

      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

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: