You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Vladimír Oraný (Jira)" <ji...@apache.org> on 2022/07/25 05:34:00 UTC

[jira] [Created] (GROOVY-10704) Random order of TraitBridge methods breaks cachablity

Vladimír Oraný created GROOVY-10704:
---------------------------------------

             Summary: Random order of TraitBridge methods breaks cachablity
                 Key: GROOVY-10704
                 URL: https://issues.apache.org/jira/browse/GROOVY-10704
             Project: Groovy
          Issue Type: Bug
          Components: bytecode
    Affects Versions: 3.0.7
            Reporter: Vladimír Oraný


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}}


{code:groovy}
class Person {
    String name
    Integer age
    Date lastVisit
}
{code}

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}}.





--
This message was sent by Atlassian Jira
(v8.20.10#820010)