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

Call to private method fails when using Custom MetaClass

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 4.0.25, 3.0.24
    • 5.0.0-beta-1
    • None
    • None

    Description

      A call to a private method in a BaseClass fails, if the MetaClass of an instance of a SubType is replace with a non-standard MetaClass.

      The attached reproducer should call the method privateMethod(), but does fail with:

      groovy.lang.MissingMethodException: No signature of method: SubClass.privateMethod() is applicable for argument types: () values: []
              at CustomMetaClass.invokeMethod(test.groovy:40)
              at CustomMetaClass.super$2$invokeMethod(test.groovy)
              at CustomMetaClass.invokeMethod(test.groovy:30)
              at BaseClass.publicMethod(test.groovy:10)
              at CustomMetaClass.super$2$invokeMethod(test.groovy)
              at CustomMetaClass.invokeMethod(test.groovy:40)
              at CustomMetaClass.super$2$invokeMethod(test.groovy)
              at CustomMetaClass.invokeMethod(test.groovy:35)
              at test.run(test.groovy:5)
      

      See also Groovy WebConsole.

      It also seams to need to be compiled with Indy, but with Indy it fails in Groovy 3.x and Groovy 4.x.

      The culprit seams somewhere around "org.codehaus.groovy.vmplugin.v8.Selector.getMetaClassImpl()" where the type of the meta class is checked, and for non standard MetaClass the code path deviates.

      And then the Sender Class "BaseClass" is not used in the CustomMetaClass anymore, then failing with it could not find the private method.

      Note: It does not fail, if the class is not compile with Indy.

      Attachments

        1. test.groovy
          0.5 kB
          Andreas Turban

        Issue Links

          Activity

            People

              emilles Eric Milles
              AndreasTu Andreas Turban
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: