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

Random order of TraitBridge methods breaks cachability

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.7
    • 4.0.5, 3.0.13
    • bytecode
    • None

    Description

      The build tools such as Gradle compares the class files and JARs containing them to determine if there is a need of recompiling the projects. Any randomness in generated classes breaks the cachablity.

      It seems to me that the order of methods generated from traits is not deterministic therefore compiling the same source code generates different class file. This can be observed for example with Grails entities.

      1. generate a fresh Grails project curl -O https://start.grails.org/myapp.zip
      2. unzip the project
      3. create a Groovy entity inside myapp/grails-app/domain/myapp/Person.groovy

      class Person {
          String name
          Integer age
          Date lastVisit
      }
      

      4. compile the project ./grailsw clean classes
      5. save the content of compiled class file in build/classes/groovy/main/myapp/Person.class
      6. recompile the project ./grailsw clean classes
      7. compare the regenerated class file with the original one build/classes/groovy/main/myapp/Person.class

      You may need to repeat the step 6 and 7 couple of times but eventually you will see there is a difference in the order of the methods annotated with @TraitBridge.

       

      Attachments

        Activity

          People

            paulk Paul King
            musketyr Vladimír Oraný
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: