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

null check for propertyMissingGet in MetaClassImpl.checkIfStdMethod considered harmful

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.6.5
    • 1.7.3, 1.8-beta-1
    • None
    • None

    Description

      In the checkIfStdMethod implementation, the code reads as follows:

              if (propertyMissingGet == null && method.getName().equals(PROPERTY_MISSING)) {
                  CachedClass[] parameterTypes = method.getParameterTypes();
                  if (parameterTypes.length == 1) {
                      propertyMissingGet = method;
                  }
              }
      

      This means once the 'propertyMissing' method is set, it cannot be overridden. This results in a problematic behavior:

      1. I set the propertyMissing for the base class. Everything works as expected
      2. Later down the road, a meta class for the derived class is initialized.
      During this initialization, the meta class gets its inherited propertyMissing method set.
      3. Then I go on to register a different propertyMissing handler for this subtype
      4. Due to this null check, nothing happens; my new propertyMissing handler will be never invoked.

      More generally, since MetaClassImpl is created on demand, it's possible that further derived types have already copied the old methodMissing property during its initialization. If my step 3 comes after that, then those further derived types will not get my new propertyMissing method.

      Attachments

        Activity

          People

            guillaume Guillaume Sauthier
            kohsuke Kohsuke Kawaguchi
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: