groovy
  1. groovy
  2. GROOVY-5390

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

    Details

    • Type: Bug Bug
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.8.6
    • Fix Version/s: None
    • Component/s: class generator
    • Labels:
      None
    • Environment:
      Linux, jdk1.6
    • Number of attachments :
      0

      Description

      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

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Unassigned
              Reporter:
              Bertrand Barroux
            • Votes:
              3 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: