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

@Lazy has incorrect behavior for static fields

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.2
    • 1.7.3, 1.8-beta-1
    • None
    • None

    Description

      The fragment:

      @Lazy static Type myField
      

      is transformed into a static private field $myField but an instance method getMyField(). The method should be static and in the case of synchronization, would need to synch on the class not 'this'. But there is also a question as to whether double checked locking is best for static, perhaps holder class idiom is better.

      Attachments

        1. groovy4222_lazy_static.patch
          2 kB
          Paul King
        2. groovy4222_lazy_static_holder.patch
          8 kB
          Paul King

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: