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

groovyc class generation kind of break default serialVersionUID generation by the jvm


    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 1.8.6
    • Fix Version/s: None
    • Component/s: class generator
    • Labels:
    • Environment:
      Linux, jdk1.6


      When using groovyc ant task for compiling groovy classes, the class generation visitor pattern creates a non transient static field with a variable name (timestamp) for each visited class.

      (cf org.codehaus.groovy.classgen.Verifier.addTimeStamp(ClassNode node) method which adds a field whose name is : "_timeStamp_239_neverHappen" + String.valueOf(System.currentTimeMillis())

      If the class has no specified serialVersionUID, the jvm will compute one during the first serialisation/deserialization. Because of this field, this computed serialVersionUID will change after each compilation, even if the class has no change whatsoever.

      A workaround is of course to add a serialVersionUID to the groovy object, but this is kind of an annoyance, because default generation just works perfectly for cases in which you use serialization for things such as cache and session management, and you don't have to enforce a process in which each developer has to manually manage that serialVersionUID manually every time the class change.

      I have the feeling that this annoyance could be avoided, if the synthetic field added by the Verifier was set as transient, and I think it would not defeat the purpose of this field (I may of course be wrong on either of those subject...)


          Issue Links



              • Assignee:
                bbarroux Bertrand Barroux
              • Votes:
                3 Vote for this issue
                3 Start watching this issue


                • Created: