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

call site caching missing null check

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.8.6, 2.0-beta-3, 1.7.11
    • None
    • None

    Description

      Luke brought GRADLE-2045 to my attention and I was able to reproduce the problem using this program:

      class Cat {
        public static findAll(Integer x, Closure cl) {1}   
      }
      
       def foo(x) {
           x.findAll {}
       }
       
       use (Cat) {
           println foo(1)
           println foo(null)
       }
      

      It should actually not matter what method or base class the category uses, important is more that a PojoMetaClassSite will be produced. The code here does this because the receiver in foo is the Pojo integer and since categories are active, the normal way of getting a MetaMethod and using that will not be applied. Instead the fallback action with the long path through the MetaClassImpl will be chosen. PojoMetaClassSite has, as all of those, a check for invalidation which includes meta class changes and a check for the receiver being still of the same class. But the class check requires a non-null receiver, which is not the case anymore at the time that foo is called the second time.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            blackdrag Jochen Theodorou
            blackdrag Jochen Theodorou
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment